Support » Plugin: Recent Posts Widget With Thumbnails » Sticky Posts don’t show when category specified

  • Resolved selenasmith

    (@selenasmith)


    I love this plugin but I’ve run into an issue. I’m using sticky posts as featured items to be listed at the top of the posts. It works fine when category is set to “All Categories” but when I specify a category (such as “Newsfeed”), the sticky post doesn’t appear. The sticky post is set to the specified category (“Newsfeed”).

    I’m also using Elementor for page layout.

    Thanks!
    Selena Smith

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Martin Stehle

    (@hinjiriyo)

    Thank you for your notice. I will publish the fix soon.

    Thanks for the quick response! 🙂

    Plugin Author Martin Stehle

    (@hinjiriyo)

    Version 6.2.1 with the fix is out now. If you like the plugin I would be glad about your review.

    Still not working. I also have the widget display 3 posts, so i’m not sure if that’s causing an issue or not. My sticky post is from May, and there are several posts since then. I’ll also check if there’s a plugin conflict.

    I’m displaying the 3 most recent posts in the widget. If the sticky post is one of the three it displays it at the top of the list correctly. However, if it’s after the first 3 posts it doesn’t display.

    Hope that helps.

    Thanks!
    Selena Smith

    Plugin Author Martin Stehle

    (@hinjiriyo)

    Does the widget filter by category?

    Yes, by one category, and the sticky post is set to that category.

    • This reply was modified 2 years, 2 months ago by selenasmith.

    I think I’ve figured out a solution. It may not be the most glamorous solution, but at least it works for my situation, lol.

    I took out the post_per_page parameter in recent-posts-widget-with-thumbnails.php

    		// standard params
    		$query_args = array(
    /*			'posts_per_page'      => $ints[ 'number_posts' ],  */
    			'no_found_rows'       => true,
    			'post_status'         => 'publish',
    		);
    

    Then I set it as an iteration in the print loop of widget.php

    ` <?php
    $xloop = 0;
    while ( $r->have_posts() and $xloop < $ints[ ‘number_posts’ ] ) : $r->the_post();
    $xloop ++;
    ?>

    Think this will work?

    Thanks,
    Selena Smith

    • This reply was modified 2 years, 2 months ago by selenasmith.
    Plugin Author Martin Stehle

    (@hinjiriyo)

    If there is no parameter ‘posts_per_page’ WordPress sets it with the default value. So I do not think that is the reason.

    Your loop just count up $xloop. Why should there be an effect?

    It looks like the WP_Query is only pulling number_posts and if there’s a sticky post within that number_posts it moves it to the top of the array. However, we have a sticky post that we’re using as a featured newsfeed item which should always appear at the top of the post even though it might be an older post and may not be within the number_posts limit. Does that make sense?

    Plugin Author Martin Stehle

    (@hinjiriyo)

    Yes. And does your loop put the sticky post on top of the list?

    Yes. Well, it’s really your loop – I’m just iterating number_posts. By that time you’ve already moved sticky post(s) to the top of the array.

    Plugin Author Martin Stehle

    (@hinjiriyo)

    Where is your loop located: before my loop or inside my loop?

    I modified your loop. (And yes, that’s not the proper way to handle things)

    • This reply was modified 2 years, 2 months ago by selenasmith.
    Plugin Author Martin Stehle

    (@hinjiriyo)

    I tried your approach and got interesting results. But I will not implement it. One reason is the case a user wants to show more posts than set in “Settings” > “Reading”. Without the parameter ‘posts_per_page’ the loop returns as many posts as defined there. The second reason is that IMO the unexpected result is a WordPress core bug.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Sticky Posts don’t show when category specified’ is closed to new replies.