Support » Plugin: Widget Logic » is_blog()

  • Clarus Dignus

    (@clarus-dignus)


    is_page() is a conditional tag that checks for all pages.

    I expected is_blog() to exist however it’s not an existing WordPress conditional tag.

    It would be useful to mention the necessary conditional logic under “Examples” on the main Widget Logic plugin page:

    is_archive() || is_author() || is_category() || is_home() || is_single() || is_tag()) && 'post' == get_post_type();

    Alternatively, is_blog() can be created by adding the following function to functions.php:

    function is_blog () {
        return ( is_archive() || is_author() || is_category() || is_home() || is_single() || is_tag()) && 'post' == get_post_type();
    }

    It might be useful if the Widget Logic plugin automatically integrated this custom conditional tag for users who are unable to edit functions.php.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Clarus Dignus

    (@clarus-dignus)

    Typo: In my code, is_tag() has an unintended additional right bracket.

    i’m using this code to display a widget if the page
    is the blog page ( its a static page designated as the blog page ) or
    if the page is showing a category ( in the array ).
    its working but if the post has two categories or is a sub category it won’t.
    what additional code would i need to display all posts?
    or is there a simpler way than to find post ids and category ids?

    if ( is_front_page() && is_home() ) {
      return false;
    } elseif ( is_front_page() ) {
      return false;
    } elseif ( is_home() )    {
      return true;
     } 
    elseif  (
     is_category (array(8,9,10,11,12,13,14,15,16,17,18,19,20,21))){
    return true;
    }
     else {
     return false;
    }

    i guess if i add is_single () it all works…

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.