WordPress.org

Ready to get started?Download WordPress

Forums

Recent Posts Widget Extended
New option - Hide Widget if there are no results (3 posts)

  1. davgarcia
    Member
    Posted 5 months ago #

    It would be great if there were an option to hide the widget if there are no results that satisfy the criteria. Currently the widget title still shows up all by its lonesome.

    https://wordpress.org/plugins/recent-posts-widget-extended/

  2. Satrya
    Member
    Plugin Author

    Posted 5 months ago #

    Hi,
    I'm sorry I dont understand with the 'no results'. When you found the no results criteria?

  3. davgarcia
    Member
    Posted 5 months ago #

    Right, so on the site I have the widget in the sidebar for all pages. And I modify the query using rpwe_default_query_arguments so that it only shows related blog posts that reference the page's topic. So if $post->ID == 2 then I add something like $args["category__and"] = array(5, 6);.

    On a few pages this very restrictive filter returns no results at all, displaying the widget title bar and nothing else. So what I did was modify the plugin code so that it runs the query first and then displays the title and results, but only if the query returned more than 0 results.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.