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?
- Get Value of Post before
- How to check if single.php has already called the_post_thumbnail function
- Bulk delete WordPress posts with phpMyAdmin
- WordPress query_posts by tag doesn’t work anymore(?)
- why does wordpress ignore the post args?
- obtain the author id given the post id
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- 2 dynamic sidebars registered, not showing up
- Dynamically switch template on click
- Get current post data into array?
- How to get posts and comments amount per hour, per year and per month?
- While loop articles – if statement order
- post category in wp_insert_post
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Multiple Loops Breaking Pages
- Adding an Archive button to posts page for administrators
- Show comment number per author per day
- How to make only posts show date
- add to end of post in the loop with plugin
- wordpress remove views from action links in a custom post
- Count number of posts of current month
- How do I Redirect a WordPress Page?
- Get all custom post types excepted some…
- Security to delete post by Admin
- Add title for previous and next posts to Yoko Theme
- Where do wordpress posts go?
- Add $values to post_class()
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- posts not showing on index.php
- How to rate a post from Admin Side / Manually?
- Images inside post title
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- Page template is accessing the incorrect posts?
- insert a warning message into post-new.php
- How to get ID of the page included with get_page()?
- Conditionals if tags exist?
- Thumbnail Image to go in the post aswell
- Getting only the URL of the post thumbnail
- Posts vs Pages and categories
- Add filter to the end of the post
- What file is the standard frontpage that lists all the posts?
- outputting posts’ taxonomies: cant get ‘get_the_taxonomies’ working
- wp_insert_post_data: Limit number of Page but Post get affected
- How to Get Posts, Including Private Ones?
- Get all comments of author’s posts
- using is_paged for hiding image on posts
- Disable link for single posts
- How to dynamically parse and transform post/page content before displaying it?
- Find the Post ID of a post from another website
- How to display all posts divided/ordered by post date? [closed]
- Can’t set Post ID properly
- Remove password protected posts from default RSS feed
- Problems with Page Not Found
- Display post changelog in post
- Notification when visitor is on specific WordPress Article
- (solved) getting post author’s user role
- Block editors annoying warnings
- Send a review notification email to admin when a post is 12 months old