First of all, please don’t use query_posts
, but a new WP_Query
.
Outpu count based on page is just a matter of a simple arithmetic operation using current page number and posts per page number.
global $wp_query;
$paged = $wp_query->get('paged') ? : 1;
$posts_per_page = 10; // feel free to change this
$args = array(
'cat' => 47,
'meta_key' => 'cb_vote_nb_vote',
'orderby' => 'meta_value',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $posts_per_page
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
$current_order = ( $query->current_post + 1 ) + ( $posts_per_page * ( $paged - 1) );
echo 'Current post order is :' . $current_order;
endwhile; endif;
wp_reset_postdata();
Related Posts:
- How to limit the number of posts that WP_Query gets?
- Should we trust the post globals?
- Random sort within an already sorted query
- how to get a different html for odd/even posts?
- How to know if get_posts() failed?
- How to display posts by current user/author in a custom page template?
- WordPress Number of Posts Not Changing With posts_per_page
- Duplicate posts
- Looping through posts per category gives same posts for each category
- How to show posts rank based on custom field value
- How do I create Comma Separated list of attached image ids?
- Trying to put an array into ‘post__in’ => array() query not working
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- Query All users that has post
- How can I get all posts data from within a paginated search result?
- How only display all post related to category
- Search query – exact post title match
- Check if post exists
- Display page content AFTER a loop of posts
- Only display posts after current date
- Get posts by multiple ID’s (query)
- How to start with post number x?
- Exclude posts with empty post_content in wp_query
- Only display a certain number of posts, dependent on how many posts there are available in a query
- Improving WP_Query for performance when random posts are ordered
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Query how many items to show in shortcode
- WP_Query Authors OR Categories
- Sticky post appears twice
- How Can I Query a Specific Page From a MultiPage paginated Post
- filter RSS feed in URL
- WordPress custom Query for Posts in Category display posts multiple times
- get query() without post content?
- Exclude the first ‘n’ number of posts of a tag from home page?
- posts_per_page option limits the number of Gallery items
- How i can limit period of post publication?
- Dynamically switch template on click
- How to get posts and comments amount per hour, per year and per month?
- Get all custom post types excepted some…
- Get all comments of author’s posts
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Counter is skipping post when I still want it visible [closed]
- Do not show children of a category
- Can’t get full post title if there a spaces in title
- How to get all post_parents of a post?
- Latest posts by category — how to exclude current post?
- Run query_posts if SESSION is empty?
- How to give classname to post if post has no content?
- Exclude some posts from displaying in wp_query based on some condition
- Related Posts function not working
- How to retrieve certain number of images from a wordpress post?
- How to convert query sql to shortcode in wordpress?
- Some doubts about how the loop work (trying debugging it)
- Adjust the order for returned posts
- Export all posts to import as product items
- get last post’s link with SQL query
- Trim posts from WP-Query?
- Custom Select Query – Selecting the Year?
- Prevent duplicate pages from being added
- Show 10 latest posts only from users with contributors role
- Trying to exclude custom posts based on date, while sorting by custom field
- WordPress, custom post type and posts query help!
- Return records between two meta datetimes saved as strings
- WordPress Query – Display 5 posts (same post type), each from a given tag
- how to add tags to post in the Loop?
- Merge get_comments & get_posts into a single query
- How to optimize posts query in wordpress
- Ignore posts content in the posts queries for internal linking
- How to search through “post title” and “tags” using WP_Query?
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- I have two post types in the same query, how can I use CSS to select only one post type?
- Bulk Post update_post_meta
- Count posts for pagination
- AJAX load more posts not using correct category and repeating the same few posts
- Numbering author posts in posts query
- How to run select query of post with category and tags?
- Sort Events by Venue Title – Sort Post set by related post ids
- Query post for today, if no post get the previous one
- Custom Select Query pagination not working properly
- Sort / Filter Queries
- Display the latest post from some selected authors
- Advanced Post Display/Pagination/Ordering
- Ordering posts alphabetically by meta keys and title
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Removing a post from the results of a WP Query
- Query posts from a specific category and selected tag
- Displaying Results From Custom Taxonomy Query
- Sort post by category using HTML Select tag
- How to store post rating system data post independent?
- Get first comment link on the post itself
- WP_Query retrieve custom posts but not the post showing
- Special Query: Title, Terms, Content – %LIKE%
- Make division in post_query?
- Display one post randomly from category on home page
- How to set value in Query Loop?
- Wp_query WooCommerce products
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- Display posts with id equal to relationship value
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Change permalinks in posts via SQL