I guess you don’t need to target a taxonomy. You can use the code below:
function query_change_function( $query ) {
$query->set( 'posts_per_page', 5 );
}
add_action('pre_get_posts', 'query_change_function');
You should wrap the $query->set( 'posts_per_page', 5 );
around with if ( ! is_admin() && is_home() ) {//the $query->set code}
to avoid it changing to 5-posts everywhere.
Related Posts:
- How to add an admin notice upon post save/update
- Passing current cookies in wp_remote_get to get Draft Post Preview
- Listen to Post action
- Manipulate post category after time
- WooCommerce – Create Products Programatically [closed]
- which action to hook to in order to perform post-publish action
- Cannot access current post’s ID in custom plugin
- Set number of article per number of page
- How to change post status from publish to draft using hook in wordpress?
- prevent showing posts of an specific category in admin posts section
- Using radio button meta data from a custom meta box
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- Global $post not working in OOP function WordPress
- Define a wordpress constant through plugin functions?
- How to get post bulk edit action trigger and get edited post ids?
- updating a post doesn’t trigger a function
- Hide a specific category in admin All Posts page (WordPress)
- Prevent Delete Attachment by URL or When Submit
- What hook do you use to update a post?
- Updating post data on save (save_post vs wp_insert_post_data)
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- Filter Hook for post table (not columns)
- why str_replace targeting pages instead just targeting post?
- Get author posts count after excluding a category
- Stop post submission without losing data?
- Cant’ Grab WordPress Built-in Posts Through Loop
- How can my plugin display a populated new post window
- search content of pages and list in wp-admin
- Finding a post’s slug
- Insert specific information to a posts of a predefined category
- Open a wordpress single post in a lightbox without the header and footer
- WordPress: Develop multiple posts with different data
- How do I change the post title’s link on the posts page?
- Update user meta when post published no working
- Fixing the WP Post Object for Custom Route
- Export Posts with specific custom fields by sql
- Custom plugin to get related posts by category
- Hide the contents for specific post
- Onclick open posts displayed in slider in a popup [closed]
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- What is the use of to_ping and pinged column?
- How do I unlock a post programmatically?
- Export WordPress Posts and Meta Information in CSV format
- How to add post count to wp_nav_menu?
- Posting From Apple Aperture?
- how to show all post in my page-grid.php template page
- How to add padding between posts
- eBooks download website, page or post?
- Remove whitespace at the end of posts?
- Add few specific post ids to wp_query
- Add filter-by-tag in the all posts admin console page
- Can I hide a specific post from latest posts page?
- Add scripts on custom post add/edit pages Not Working
- Getting current post ID in functions.php
- Understand post type
- How can I show wordpress posts based on author?
- Avoid duplicate post from same Taxonomy
- Can I divide the pages into categories?
- Change post order random through out the entire WordPress
- Posts gathered from WPEMatico feeds are being mixed in different languages. Polylang is used for language separation
- Shortcode and whitespace formatting problem
- Delete pubished and unpublished posts with wp_delete_post?
- How to remove in-line style of WordPress’s post content only?
- How can I add content to a post that only shows in single-post mode?
- How to Get Posts, Including Private Ones?
- How can I determine where I want to edit in the backend (server)
- Archive template combined with post slider and regular posts
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- Removing all post tags except a given list
- Bootsrap carousel for post
- WordPress display posts category in loop
- How-to show last 5 posts
- Get timestamp of latest post in C#
- How to draft posts after being published with x days
- How to highlight or show new to the particular posts list
- Display latest posts from a specific categories
- wp_insert_post() Add and specific ID to the body of that
- out of nowhere
- My posts are getting to Auto draft when I try to Publish
- Make current post the homepage
- Display all tags even if they are not assigned to a post
- No comments allowed
- Get post by two meta key but order by one of them
- Page Template Drop down disappears when static front page is selected
- Posts on Sidebar only
- Advanced Post Display/Pagination/Ordering
- Sorting Posts by Date – get_blogs_of_user_id()
- How do I paginate posts page with $wpdb?
- Can I hide only one category from admin post list?
- Get most recent posts by category that aren’t first overall [duplicate]
- Trying hard but can’t hide featured post/page from grid
- Posts in Admin only display 1 Post instead of all
- Post thumbnail is not shown in wp-admin
- WP_query sort by custom meta_key “price”
- How can I get the first post THIS SAME CATEGORY?
- How do I make it so that WordPress displays the post as a heading, followed by a written excerpt?
- CSS code for “inserting a custom post divider” after each post
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- Show Next/Previous without Link