Last active
September 11, 2021 06:40
-
-
Save mdjwel/31307c9b910659c4113b924da4c20638 to your computer and use it in GitHub Desktop.
WordPress Custom Query Based Condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$popular_post = new WP_Query(array( | |
'post_type' => 'post', | |
'posts_per_page' => 5, | |
'meta_key' => 'post_views_count', | |
'orderby' => 'meta_value_num', | |
'order' => 'DESC' | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* custom_post_query_with_pagination.php | |
* Show pagination in custom posts archive (loop) by custom post query $paged var | |
**/ | |
global $wp_query; | |
global $paged; | |
$temp = $wp_query; | |
$wp_query = null; | |
$wp_query = new WP_Query(); | |
$wp_query->query('showposts='.get_option('posts_per_page').'&post_type=t-shirts'.'&paged='.$paged); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment