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
- Get post content from outside the loop
- How to Change Loop to Order Posts by Views (using wp-postviews plugin)
- Display subpages under parent page as a list within a loop
- When to use wp_reset_postdata();
- Related Posts loop – offset
- Showing current subcategory
- Exclude category from loop not working
- Generating dynamic Tabs with multiple query post loop
- How do I override part of the main loop in my child theme?
- get_posts that match a user-specified value on a page
- get_the_title outputs title until spacing; it does not get full length of title
- List all posts in a category with query_post() function
- Custom loop not working
- How can I display other user avatars on an author profile page?
- Loop Offset for tag based “Related Posts”
- How do I put my frontpage featured image in a page template for home.php?
- Randomly display post based on meta value. (Kind of Priority/Weight)
- How to break up php code to avoid echo
- static page with multiple loops breaks post pagination
- Help with if and else statement
- How to display just video post format?
- Is it possible to get a post ID of a 2 different custom post types loop embedded in the same post to perform update_post_meta from the frontend?
- Sorting posts to make those with post thumbnail show up first
- Best way to check if a post with specific meta exists
- Default Template infinite loop of Title
- Error in Wordprewss loop for page template [closed]