In your main loop file, check the $args. It filters the query. you can use the same query on other pages using your own options.
suppose, on another page, you want to fetch the posts of a different category. your query parameters may be like:
$args = array(
'post_type' => 'post',
'cat' => 'DIFFERENT_CATEGORY',
'posts_per_page' => 2,
'paged' => $paged
);
change the DIFFERENT_CATEGORY with specific category ID.
then you can pass these arguments to WP_Query as in your loop.php.
if your page has multiple such queries, you should use wp_reset_query
before running further query. More her: http://codex.wordpress.org/Function_Reference/wp_reset_query
Does it help?
Related Posts:
- Grab the first paragraph of each post
- Single Page WordPress Theme – Using page templates
- First post of each category
- query posts in wordpress
- posts_nav_link(); not showing up on static pages
- Get list of months with posts
- Finding Page Template and Displaying Content
- How WordPress converts URL to $query_string
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- Some doubts about how to show posts in a custom theme?
- Storing query variable and then using wp_reset_query
- paged > max_num_pages won’t throw 404
- Echo all category names, apart from one
- how to get the post attachement image in full size?
- Change image size depending on page
- How can I prevent posts with no title showing up in my query?
- WP_Query not getting all posts, just tagged posts
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- Pagination and multiple loops
- Best practice for implementing a blog page / section in wp_menu_nav()
- List categories of a post hierarchically?
- White screen of death on index.php page 3 and above?
- Local variable name in setup_postdata()
- Problem with pagination link (error 404)
- control posts order by select option
- How get the 10 most viewed pages (not post)
- How to close open divs in post loop
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- issue displaying variations in custom template using WPeC 3.8.9.2
- Why am I getting posts back when I shouldnt
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- Add a dropdown to theme customizer
- What is the problem if I use CDN in my WordPress parent theme(built using bootstrap)?
- How to check if post has any tag?
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Pagination Not working on Home Page with 2 Query
- Two queries on the same page with pagination
- Which is the simplest theme for WordPress to use it as your base?
- Adding WordPress colorpicker in widget settings
- A theme that follows all the best practices to learn from?
- get_post() function returns post even if it is trashed
- How to highlight the current page in the nav menu?
- Add social icons in a theme through custom admin menu
- file_get_contents Not allowed in Themes?
- Why is this coming back as null? Thats wrong. There is one post
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- How do I remove twentyten without ruining what I did?
- Custom theme not visible in Appearance
- Developing WordPress Theme using CSS framework like Bootstrap
- WP_Customize_Color_Control omitting # symbol
- Theme translation not applying
- How to add filter the post thumbnail before save in database?
- Theme Inspector “X-Ray”
- Acivate all themes multisite wide automatically
- WordPress Theme Creation [closed]
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Integrate WooCommerce theme with a WordPress theme [closed]
- Managing WordPress Theme
- pagination for a custom loop with multiple post types
- Simple child theme modification but links are broken
- Making a WordPress theme based on twentyten
- theme style is applied on the dhasboard rather than the website
- What template file is used for homepage pagination?
- WP_QUERY wrong ammount of posts
- Alignment Problem [closed]
- What $handle does WordPress use for a theme’s implicit style.css?
- how to handle the loop using filling bootstrap grid structure?
- Unwanted empty line at the beginning of document
- Why is my container argument not working for wp_nav_menu() [closed]
- best practices for updating wordpress theme
- I am officially missing something about transient posts
- help needed for suit designing tool
- Custom post type pagination error
- How can I sort my loop based on meta data, using a form?
- How to modify theme content in Thematic?
- Exclude parent categories from the_category() within the loop
- Host Private Custom Theme
- My wordpress theme name isn’t updating straight away
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Customizer API Multi Sections in single Panel
- WordPress theme options checkbox default checked state
- Copying a modified theme from one wordpress site to another wordpress site [closed]
- How can I change this SVG shape that’s generated?
- How to show some of category in wordpress
- using themename_the_custom_logo() in template-tags?
- Creating a theme just to deploy a single page
- Paging works correctly on local version, but not live?
- Custom page template not showing on page creation
- Weird ‘theme update’ error [duplicate]
- Pagination not working with WP_QUERY
- wp_query pagination links producing 404
- WordPress two sidebar layout or theme
- Pagination problem with multiple loops on the same page
- Add Dynamic Sidebar to Exisiting WordPress Theme [closed]
- WordPress post pagination on custom template not working
- How can I install my custom-made theme on a wordpress.com blog? [closed]
- WordPress Loop with Custom Post Type for Bootstrap Accordion [closed]
- Get posts after calculating meta key
- .submenu class missing in output from wp_nav_menu
- Show number of posts AND number on current page (cannot make it work)