• Hi,

    I’m using Utlimate post widget to let me display sticky posts on the right sidebar on a website.
    It works well except that when there are no sticky post, the widget still display the last published post…

    I need the widget to display only sticky posts and to display nothing if there are no sticky posts…

    Thanks in adavance for any solution, advice or workaround…

Viewing 1 replies (of 1 total)
  • Thread Starter bendev

    (@bendev)

    Here is the workaround I’ve made if it can help someone:

    function Hide_Empty_WidgetStickyPost() {
    	$sticky = get_option( 'sticky_posts' );
    	if ( isset( $sticky[0] ) ) {
    		// nothing is done if there is at least one sticky post
    	}
    	else
    	{
    		// if there is no sticky post, then then hide the widget
    		?>
    		<style type="text/css">#sticky-posts-2{display:none;}</style>
    		<?php
    	}
    }
    add_action( 'wp', 'Hide_Empty_WidgetStickyPost',99);
Viewing 1 replies (of 1 total)
  • The topic ‘Only sticky-post filter: widget is still displayed when there are no sticky post’ is closed to new replies.