How to remove only the latest sticky post from the loop

So if you’re getting the sticky-post you want removed anyways I want to do that coz I will make another query to render the latest sticky post on top of the main loop in a separate ‘div’ Just make a variable, $excludeSticky, with it’s ID, and add an ‘post__not_in’ => array($excludeSticky), argument in your query.

How to display sticky or latest published post on the current category page it belongs to?

This code is certainly not perfect but it actually does the job : <?php // Store the current category ID : $current_object = get_queried_object_id(); // Get sticky post : $args = array( ‘posts_per_page’ => 1, ‘post__in’ => get_option( ‘sticky_posts’ ), ‘cat’ => $current_object, ‘ignore_sticky_posts’ => true, ); $sticky_query = new WP_query( $args ); // Get … Read more

How to display sticky post with custom html

Your code looks odd to me, typically to insert something between posts you add a counter and count each loop, then add custom code on a particular count, this is for the main loop, for a non main loop or secondary loop us wp_query. <?php if (have_posts()) : ?> <?php $count = 0; ?> <?php … Read more

Why: sticky front page code, shows latest non-sticky on logged-in front page

If you want both logged in and non-logged in user to see the same thing then you only want ‘published’ post status, at least it doesn’t make sense to me to show ‘private’ posts to non-logged in users. Alter you query to include that condition. $most_recent_sticky_post = new WP_Query( array( ‘post_status’ => array( ‘publish’ ), … Read more

Exclude current sticky post

This should do: // Get sticky posts $sticky = get_option(‘sticky_posts’); rsort($sticky); $sticky = array_slice($sticky, 0, 3); // Check if current post is inside foreach ($sticky as $key => $value) if ($value === $GLOBALS[‘post’]->ID) { // … and remove unset($sticky[$key]); break; } $query = new WP_Query( array( ‘post__in’ => $sticky, ‘ignore_sticky_posts’ => 1, ) ); If … Read more

Display image for first sticky post only

Try this : <ul> <?php $args = array( ‘category_name’ => ‘महाराष्ट्र’, ‘post__in’ => get_option( ‘sticky_posts’ ), ‘showposts’ => ‘6’, ); $the_query = new WP_Query( $args ); $count = 1; while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <li> <?php if ( 1 == $count ): ?> <div class=”thumbnail_class”><a title=”<?php the_title(); ?>” href=”https://wordpress.stackexchange.com/questions/150086/<?php the_permalink() ?>” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)