• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Widget styling (visibility) customisation using conditionals

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Widget styling (visibility) customisation using conditionals

This topic is: resolved

Tagged: widgets conditionals customisation

  • This topic has 3 replies, 2 voices, and was last updated 12 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • April 23, 2014 at 5:30 pm #102111
    Robodashy
    Member

    Hi helpfull forum community!

    I have included a widget area at the bottom of certain pages to include the "Genesis - Featured Posts" widget, selecting featured posts specific to that page's category and displaying these at the bottom.
    I'm wondering if there is a way to have that widget area show up only if there are news items within that category. I would assume it's an if statement or something of the like:

    add_action( 'genesis_before', 'do_awesome_stuff' );
    function do_awesome_stuff {
    if (get_category('blah')->category_count > 0) {
    // do stuff which removes widget area ... which is where I'm stuck
    remove_action( 'something_goes_here' );
    }
    }

    I think the reason I'm stuck is because these widget areas have all been added through the Extender Custom settings of the "Genesis Extender Plugin" (awesome plugin) - so I'm not sure how to call in that certain widget.

    Am I on the right track? Or way off?

    Any help would be greatly appreciated.


    The large print giveth, and the small print taketh away.
    – Tom Waits, “Step Right Up”

    May 1, 2014 at 8:17 pm #103266
    Tom
    Participant

    Some of us are familiar with Extender (and some more than others! 🙂 ) but I expect you'll find better expertise over in the forums at CobaltApps. You might also look at the Widget Logic plugin, which allows you to run custom PHP from within any given widget.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    May 1, 2014 at 8:23 pm #103267
    Robodashy
    Member

    Hi Tom.

    Oops, I should have closed this one off as resolved.

    It was a mix of php and javascript scorcery. For anyone else's future reference I've posted my solution below (I've tried to comment it as much as possible):

    //* Add support for hide news widgets if no posts
    add_action( 'genesis_before', 'ybs_empty_category' );
    function ybs_empty_category() {
    //* Declare variables for each category you want to check
    $charter=get_posts('category_name=charter-news');
    $fares=get_posts('category_name=fares-and-tickets');
    $school_transport_news=get_posts('category_name=school-transport-news');

    //* Make sure you're on the right page, then check if the category for that page has posts
    if (is_page( 'charter' ) && $charter->post_count == 0) {
    //* Use PHP to echo out javascript - See, SCORCERY!!!!
    echo "
    <script type=\"text/javascript\">
    jQuery(document).ready(function() {
    document.getElementById('news_charter').style.display = 'none';
    });
    </script>";
    }
    }


    The large print giveth, and the small print taketh away.
    – Tom Waits, “Step Right Up”

    May 1, 2014 at 9:17 pm #103273
    Tom
    Participant

    Thanks for the update and the code.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble