Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #660270

    Hello,

    When creating a featured image slider that only displays a single post, it does not fetch the first sticky post in the categories chosen, but rather the most recent one. Why, and how can I make it display a sticky post first, if there is any?

    • This topic was modified 8 years, 5 months ago by emilbroll.
    #660595

    Hey emilbroll,

    Please send us a temporary admin login so that we can have a closer look. You can post the details in the Private Content section of your reply.

    Regards,
    Rikard

    #660835

    The admin part of the site is restricted by a proxy filtering out IPs, and I cannot add other IPs, is there another way that you can help me?

    #662047

    Hi,

    not sure what you mean that’s why it would be best to look at your backend. But can you explain further please? what exactly is the issue about? maybe we could try to reproduce it on our end. Use screenshots to make things clear for us (imgur.com, dropbox).

    Best regards,
    Andy

    #662384

    Hey,

    Ok, I’ll try to explain – we use a featured image slider as a sort of “header” for our site, with only one slide (so it’s like a color section with an image and a title).

    In other elements that display (multiple) blog posts, we can make any sticky posts appear before the other posts (like the expected behavior is, but Enfold doesn’t respect/follow) using this bit of code:

    add_filter('the_posts', 'bump_sticky_posts_to_top');
    function bump_sticky_posts_to_top($posts) {
        foreach($posts as $i => $post) {
            if(is_sticky($post->ID)) {
                $stickies[] = $post;
                unset($posts[$i]);
            }
        }
        if(!empty($stickies))
            return array_merge($stickies, $posts);
        return $posts;
    }

    This obviously won’t work on a query that only returns one result – our featured image slider – so we need a more viable solution.

    So the question is really, why doesn’t Enfold respect sticky posts (in the way that the most recent sticky post will be displayed first in any case), and how can we ensure it does display the sticky post first in cases where sticky posts are outside of the query bounds (post nr. 11 in query e.g., while query only asks for 4 posts).

    #663662

    Hi,

    Thank you for the info. Please add this in the functions.php file:

    add_filter('avia_feature_image_slider_query', 'avia_feature_image_slider_query_mod', 10, 1);
    function avia_feature_image_slider_query_mod($query) {
    	$query['posts_per_page'] = 1;
    	$query['post__in'] = get_option( 'sticky_posts' );
    	$query['ignore_sticky_posts'] = 1;
    	return $query;
    }

    This will return one of the sticky posts only.

    Best regards,
    Ismael

    #667229

    Hey, thank you, that works like a charm. :)

    #668365

    Hi,

    Great, glad we could help :-)

    Please open a new thread if you should have any further questions or problems.

    Regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Sticky posts in Enfold blog elements’ is closed to new replies.