How to show sticky posts on all pages of the pagination, not just the first page?
How to show sticky posts on all pages of the pagination, not just the first page?
How to show sticky posts on all pages of the pagination, not just the first page?
We all know that ignore_sticky_posts is used to exclude sticky post from your custom query. – No, this assumption is wrong. What ignore_sticky_posts means: Even though in natural English, ignore_sticky_posts sounds like WordPress should ignore all sticky posts from the query, in reality that is not what WordPress does. Instead, you should read ‘ignore_sticky_posts’ => …
I make sticky post for my archive page for custom post type with ACF field and loop is not working
You can try this SO question Pagination when using wp_query? Notice that their example uses the $query variable for the WP_Query instance, while your code uses $the_query. Also notice that they use paged property in the array that is being passed into WP_Query
It is not entirely clear what you are trying to do but sticky posts should be at the top– that is, the first posts displayed– already unless you have made an effort to prevent that. That is the default. I just tested this with your query, changing only the category ID to something that exists …
try and add this before your code: <?php if ( have_posts() && is_home() && !is_paged() ) : ?> <?php the_post(); ?> <?php get_template_part( ‘content’, get_post_format() ); ?> <?php endif; ?>
I think you should add a css class and in your loop, put a $i and let $i run, if $i == 2 then you add the css class attribute to that sticky post. $i = 0; while( have_posts() ): the_post(); $i++; if($i == 2): $css_class=”top-sticky”; else: $css_class=””; endif; endwhile; wp_reset_postdata();
You’re going to want to use responsive images in WP 4.4. Not a heck of a lot of documentation out yet but refer to this WP Core article Responsive Images in WordPress 4.4. Here is the example they give. <?php $img_src = wp_get_attachment_image_url( $attachment_id, ‘medium’ ); $img_srcset = wp_get_attachment_image_srcset( $attachment_id, ‘medium’ ); ?> <img src=”https://wordpress.stackexchange.com/questions/211913/<?php …
WordPress saves sticky posts inside the option named sticky_posts. You can retrieve them via get_option(‘sticky_posts’). With that knowledge it is possible to change the query to only query for sticky posts, you usually do so via the pre_get_posts hook. add_action(‘pre_get_posts’, ‘WPSE_home_only_stickies’); function WPSE_home_only_stickies($query) { // only run for homepage & main query if ($query->is_home() && …
your problem is that in the first loop you overwrite $do_not_duplicate for each post in the loop so at the end you only have the id of the last post. if you change $do_not_duplicate into an array then you can add each post to the array: //before the loop $do_not_duplicate = array(); //in the loop …