Sticky Post Doesn’t always work
Sticky Post Doesn’t always work
Sticky Post Doesn’t always work
Pin posts to top of custom loop
How do you get sticky posts to work with categories?
In your query posts array add this: ‘meta_key’ => (meta key name in database), ‘meta_value’ => 1 To make it at the top use two queries. One for the top first post and one for the rest of the posts/pages. so your whole query will look like this: <?php query_posts(array(‘showposts’ => 1, ‘post_parent’ => $post->ID, … Read more
you don’t need if/else on the counter, just check if $count == 3 or 5 to inject a sticky post, insert a regular post in every iteration of the loop, and increment the counter at the bottom.
What you’re looking for is best achieved using a custom query: $top = new WP_Query( array( ‘category’ => ‘YOUR_CATEGORY_SLUG’, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 1 ) ); if( $top->have_posts() ) { $top->the_post(); // Do things as if we were in the loop… } By default, sticky posts are brought to the top … Read more
Check if »sticky« There’s the is_sticky()–Conditional Tag, which you can read about in core here. How-to mark as »sticky« This works for posts, that have the “stick to the front page” check box checked: How »sticky« works internally So basically the function checks if the post-ID is inside get_option( ‘sticky_posts’ );. That means that you … Read more
The problem is that on your first page you ask for, lets say, 7 ‘normal’ posts. So it displays the latest 7 posts: e.g. 15-9. On page two you are telling WordPress I want 8 posts per page and I want the second page. The internal logic is that if you have 8 posts per … Read more
DO NOT USE query_posts() FOR CUSTOM LOOPS! Use WP_Query() instead. <?php $paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1; $custom_cat_query_args = array( ‘paged’ => $paged, ‘category_name’ =>’home,tumblr’ ); $custom_cat_query = new WP_Query( $custom_cat_query_args ); By default, ignore_sticky_posts is set to 0, or do not ignore. So, the custom loop should handle sticky … Read more
This may get a bit complicated, I would recommend not adding the sticky feature to other post types if you want to query them specifically, and instead using post meta to designate custom types as “sticky”. If you use the sticky feature on multiple post types, you’ll get unexpected results with the following code, as … Read more