Based on data from your Gist, the following pre_get_posts
condition should work to limit your posts per page.
add_action( 'pre_get_posts', 'my_set_category_posts_per_page' );
function my_set_category_posts_per_page() {
global $wp_query;
if ( 'category_sticky_post' === $wp_query->query_vars['meta_key'] ) {
$wp_query->set( 'posts_per_page', 8 );
}
}
Related Posts:
- Insert/sticky specific post into Loop at specific location
- Two loops by pre_get_post on same page
- Make blog page show 10 on first page, 9 on every other page
- Exclude posts from main loop based on meta value
- pre_get_posts for two loops on same page
- Sanitize Custom Field Value in Meta Query
- Modify the main loop to display current month / year
- Change post order by meta key, per post basis
- Exclude Posts Using Meta Query and User Meta
- pre_get_posts main_query not displaying after applying tax_query filters
- Query counting excluded category on paged loop
- Get query result before posts are displayed?
- How to use orderby on meta_value when using Pods custom database table storage
- How to split a loop into multiple columns
- Is it necessary to reset the query after using get_posts()?
- Using the Loop to show all levels of subpages under a parent page? Halfway there
- Cleanest Way to Select Every Second Element in a Loop?
- Get post by page name or slug
- save_post + insert_post = infinite loop
- Get ID of a page containing secondary loop in content
- ACF Repeater loops and resets – where is the reset_rows() documentation? [closed]
- Why do themes have `while( have_posts() )` in templates like single.php?
- What is best way passing variables to theme templates and using them different places like widgets?
- Apply styling only to first page sticky posts
- Exclude category by slug for for each loop
- Too many nested wp_query loops in this hypothetical query?
- pop-up lighbox with AJAX
- Load comments per post on click with AJAX
- The main Loop is not starting in a custom blog template page
- WordPress Loop – Style rows of posts differently
- connect last post with first post
- Using pre_get_posts to filter one loop in a multiloop archive
- taxonomy tags 404 to custom post types
- Breaking the loop?
- Only display videos and images in the_content() within loop
- woocommerce stored variable
- Query last updated posts (posts updated in the last 24 hours)
- A smarter way to display multiple loops inside a page template
- Posts will not display on page-mypage.php
- Publish Categories for a particular Author on a given Post
- How to print out menu names in the foreach loop?
- How can I paginate this?
- Obtain page data and use regular loop
- How can I load posts starting from, and including, the current post?
- Why does `inclusive` not work in this wordpress loop?
- How do I automate multiple category loops?
- Change date format
- Loop inside query
- How to stop the continuation of posts on the second loop from where the first ended
- In Custom page – next_posts_link Not working while previous_posts_link is working
- something strange is happening to my code
- How to modify search.php to not show pages only show posts
- How do I display the latest posts from three different categories?
- Show articles in Pair
- Randomly display post based on meta value. (Kind of Priority/Weight)
- Make a loop to return x number of posts, but only if they have content or excerpt
- Closing the loop…featured image variable based on post id
- How do you stop the rendering of the website to have something display on the front-end?
- add_action in the loop hooks
- How to render the single post template with the post name?
- Reset Loop get_posts();
- new custom theme – posts displaying on top of one another
- Offset Loop by 1 , Limit next loop to 1 (Most Recent) Post
- Building a form with WordPress, and also pulling that data for a user page
- How to show multiple attachements together with Scribu’s Posts 2 Posts connector?
- Custom Header added within Dashboard pages, is this possible with custom template files?
- Loop order issue with Ajax filter
- Database query and get_user_meta return incorrect data
- Need to while loop and display contents in the subfield of a group field given by ACF
- How to display a loop of custom post types in columns
- Why my loop is repeat?
- Excerpts not showing on main page
- dispaly all hierarchical post types from a taxonomy
- WordPress Modal showing posts not working properly
- Query posts and display all dates in repeater field in chronological order
- 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?
- Multiple loops in set intervals with code in between
- Loop shows post 5 times in a query
- Attachment Metadata inside of Loop
- Modify widget to output posts in custom order
- Make custom WordPress comments list
- Template included with plugin doesn’t return all posts for custom taxonomy
- Limit article to 100 characters. Can’t use the_excerpt…
- Default Template infinite loop of Title
- Adding pagination to WP_Query [duplicate]
- Insert/sticky multiple posts in multiple positions
- This webpage has a redirect loop issue with SSL page
- Buddypress Group Activity Loop Filter activity type [closed]
- Stuck with conflicting loops on page template
- Change the way wordpress outputs images or image galleries
- How can I access ‘key’ and ‘value’ from an array in a for loop?
- How to get current page id and compare it to looped pages inside the same page?
- Show amount of posts created today above loop?
- How to create WordPress loop with combination of 4 and 2 columns twitter-bootstrap?
- posts_nav_link() not working on index.php
- How to add custom HTML markup and classes to the_content()?
- $do_not_duplicate is not working in genesis theme
- Loop displays current page
- Tags outside the loop
- I make sticky post for my archive page for custom post type with ACF field and loop is not working