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?
- Trying to create a cutom query with pagination and page 2 breaking. Any help?
- How to show user online status on their posts?
- Blog post per page setting conflicting with custom WP_Query?
- Edit footer via customizer
- create category on theme setup
- Theme Development: Starter Content after hook
- Storefront child theme not applying parent theme [closed]
- WP_bootstrap_Navwalker_issue [closed]
- Custom get_the_excerpt() only works on first post
- WP_Comment_Query – Get comments and answers separately
- Font Awesome 5 Free – far working but fas is not? [closed]
- excerpt() shows different result between remote and localhost(development environment)
- Change locale by detecting viewer’s browser language setting and let them choose prefered language after
- Why is it needed to enqueue parent stylesheet in child theme?
- posts_per_page not working for first page of pagination
- Folder name for a pro version of a WordPress.org theme?
- Prefix best practice, should we use framework name or theme name?
- Is there any WordPress theme for Self Storagae just like Spacer [closed]
- Theme Javascript.php Overwritten Nightly [closed]
- Customizer: save setting/control content to post/page
- Two loops on archive page
- WordPress Unite Theme: Footer isn’t sticking [closed]
- WordPress get_template_part() function not working
- Check if loop has any categories?
- Is accessing theme and using customizer GPL distribution?
- loading blank white screen of slide
- Where am I doing wrong in my theme menu?
- How to add Space between sidebar and footer widget in WordPress theme [closed]
- How to : pagination in 3 different custom loops on the same page
- Child Theme’s style.css not loading in mobile browser
- How can my theme allow users to take advantage of advanced html tags in posts
- How to make search for posts using get method?
- Multiple Loops on category.php with pagination on last loop
- Theme Inspector “X-Ray”
- Migrated WordPress site renders Chinese
- Acivate all themes multisite wide automatically
- How to enqueue javascript for WP Customize options sidebar?
- WordPress 500 Internal server error when activating custom theme [closed]
- Call to undefined function add_menu_page() on theme activation
- How to Find the Page the Front Page is Using?
- How to place HTML tags in content from the_content()?
- correct tags for validating input types
- WordPress Theme Creation [closed]
- Custom loops, sticky posts, and pagination nightmare
- pagination not working for category.php (custom post types in categories)
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Customize how a WordPress theme looks like in the Theme Selector
- How to set a page as homepage in stead of the newspages?
- Customizer – loading settings/controls/sections/panels based on a id/page id
- Renaming a theme so it aids SEO and the theme used is hidden
- Integrate WooCommerce theme with a WordPress theme [closed]
- Admin: sub menu doesnt display under apperance when activate my themes
- Automated Footer information
- Widget Option is Missing
- How do you use WordPress for a website that’s not in a blog format?
- How to query the latest 5 posts and sort them by title?
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Overrite parent functions using child functions
- Best way to develop a new theme on a live site, with new content? [closed]
- How do I make the most minimal vanilla theme possible with nothing but raw content?
- Can I Set Up Session in WordPress Custom Page
- Does code in function.php differ from theme to theme
- How do I get my custom query to work with search results after the first page?
- WordPress 3.8 Backend Admin Color Scheme add more scheme how to do?
- Is it acceptable for a WordPress theme to not accept widgets?
- WordPress Theme Validator?
- Get the amount of posts on a given page
- Should all references to a text domain be to my current theme?
- Theme thumbnail in dashboard