[Resolved] Top Bar Widget only on home page

Home Forums Support [Resolved] Top Bar Widget only on home page

Home Forums Support Top Bar Widget only on home page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #626558
    Ria

    I have a static home page on a fairly large site. I have a top bar widget area set up that looks and works great – but I want it to load ONLY on the home page, not site-wide. I don’t want to have to manually click the “disable elements” in the editor for this on every page/post/archive. I don’t want to use css to ‘display:none’. And I don’t want to install a big widget plugin just for this one simple task.

    What I want is to use a simple line of conditional PHP code in functions.php to do this. I know it’s simple, but I’m not a PHP coder, so not able to put the pieces together on my own. So far, all I have is:

    <?php
    if ! is_front_page() || if ! is_home() {
    // Put code here to not load the top bar widget.// < - this is the part I don't know!
    }
    ?>

    Can anyone help me with this?

    GeneratePress 2.1.3
    GP Premium 1.6.2
    #626736
    Leo
    Staff
    Customer Support

    Hi there,

    This would be super easy and no code required using the upcoming Elements module in GP Premium 1.7.

    It’s currently in second beta so pretty stable in my opinion. Would you consider it?
    https://docs.generatepress.com/article/beta-testing/

    #627381
    Ria

    That’s great but even though I’ve activated beta updates on this dev site, I’m not getting any beta updates at all? Still sitting here with GP Premium v1.6.2. I wasn’t even aware there was a beta 1.7.

    Is there a way to access/download/install the beta?

    Or, can you help me with that line of PHP code I need?

    #627398
    David
    Staff
    Customer Support

    Hi there,

    sometimes there can be a 24hr delay for the WP cache to clear for the beta to show. I’ll let Tom know as he is been looking into a couple of reports regarding this. But you may want to try clearing any server caches and then check the WP Dashboard > Updates and span the Check button a few times.

    In the meantime you can try adding this:

    add_action( 'wp', 'db_disable_topbar' );
    function db_disable_topbar() {
      if ( ! is_home() && ! is_front_page() ) {
        remove_action( 'generate_before_header','generate_top_bar', 5 );
      }
    }

    https://docs.generatepress.com/article/adding-php/

    #627403
    Ria

    Thank you, David! ๐Ÿ™‚

    #627411
    David
    Staff
    Customer Support

    You’re welcome. Hopefully the Beta (or live version) of 1.7 reaches you soon. It really is something special ๐Ÿ™‚

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