Thanks to tips given by the commentators I was able to achieve this 🙂
<?php
if ( is_front_age() ){
$most_viewed_posts = new WP_Query( array('v_sortby' => 'views', 'v_orderby' => 'DESC', 'showposts' => 10, 'cat'=> 3) );
}
while ( $most_viewed_posts->have_posts() ) : $most_viewed_posts->the_post(); ?>
//post structure
<?php wp_reset_postdata(); ?>
Related Posts:
- Post Loop not Returning Permalink
- get_posts and wp_autop (remove filter)
- Is it necessary to reset the query after using get_posts()?
- WP_Query vs get_posts
- How to return results of a get_posts() in explicitly defined order
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]
- Retrieving 3 latest post from each of 5 different custom post types
- Multiple posts with one loop iteration
- Get posts that matches specific terms of multiple custom taxonomies
- How to Loop within a Loop (Display Children and then Grandchildren)
- Exclude first 2 posts with meta_key from loop
- Is get_posts() more efficient than The Loop?
- Better way to display posts from specific categories, in a grid layout
- How to get_posts where ‘menu_order’ is more than 0/zero?
- popular post weekly and monthly
- Display the_content on click jquery
- 3 Posts in Loop, Show Stickies First
- Inserting custom data to the_post() during loop
- What is the maximum number of posts a WordPress loop can work with?
- Why only one post (and no pagination) on this variation of the loop?
- Query last updated posts (posts updated in the last 24 hours)
- Displaying terms based on loop posts?
- Sort posts by most recently modified
- A smarter way to display multiple loops inside a page template
- Duplicated posts on category page
- Make blog page show 10 on first page, 9 on every other page
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- How to display posts by vote count and if no value continue with latest posts with no votes?
- Show all posts using the template page and the loop?
- Showing sticky posts with get_posts()
- How do I paginate a get_posts() request inside another page loop (Paginating childpages)
- Both a page loop and posts loop on the same page
- How to get The Loop working with $wpdb->get_results()
- Exclude first post (sticky or not) from the loop using query_posts()
- How to order by multiple fields using standard query_posts?
- Multiple get_posts() queries on one page
- Pagination not working in category listing [duplicate]
- How can I improve the performance of this query_posts loop?
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- Output meta into arrays
- Adding div after every two post on main loop! Why will first post not get counted?
- Get post offset/posts page offset in single post page (outside the loop)
- get_posts output always same post
- How can I access specific posts brought back by query_posts?
- Separate First Post Loop
- Query posts only with actual text content (not including shortcode or images)
- query_posts clarification needed
- get_posts() forcing ignore sticky posts on main loop
- Exclude current post ID from loop in sidepbar.php
- loop inside a loop : search for posts in the same category
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Why does my WP_Query pagination on a custom page.php only loads the homepage?
- Get a Post Loop based on Logged in User information into a Shortcode
- php loop error for count posts in category
- how to add 4 post in one carousel slide
- Create a hierarchical loop at predefined markup requirements
- Ordering Posts by parent category, name ascending
- numberposts not responding to wp_reset_postdata()
- Query counting excluded category on paged loop
- query_posts ignores the argument
- The Loop isn’t working
- Need some help with “the_widget()” function
- Is there a way to target only images within the loop?
- Twitter bootstrap carousel multiple items in carousel
- show posts from one category with comments only
- Show last post from multiple categories using wp_list_categories
- Least Number of Loops to Create Custom Homepage?
- How do I correctly query posts from a post ID?
- Question about custom plugin
- How to do query_posts on tags pages
- show custom post’s post in two different divs [duplicate]
- Limitless amount of posts in custom archive page
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- How to fix pagination for custom loops?
- Jquery Slider for profile template
- Counting the posts of a custom WordPress loop (WP_Query)?
- if ( is_home() && ! is_front_page() )
- Get excerpt using get_the_excerpt outside a loop
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- How do I exclude a custom taxonomy from the post loop
- Get post content from outside the loop
- Why should I put if(have_posts()), is while(have_posts()) not enough?
- Display featured products through custom loop in woocommerce on template page
- Split Content and Gallery
- Some doubts about how the main query and the custom query works in this custom theme?
- How to get Author ID outside the loop
- How to get posts published between a date and today?
- How can i display the content in plaintext
- How to get post content by calling ajax?
- Redirect loop when trying to login to /wp-admin/ [duplicate]
- How to split a loop into multiple columns
- Get the ID of the latest post
- How to show related posts by category
- Query Posts or Get Posts by custom fields, possible?
- Is there any difference between the_title() and echo get_the_title()?
- AJAX with loop filtering categories
- Do I need to use The Loop on pages?