• Resolved WOWTALKS

    (@wowtalks)


    Hi Evan,

    I want to display the hero widget on all pages of my website,

    I included the code you mentioned before in my MU plugin but it hasn’t worked:

    The following code you’ll want to add to your mu-plugin is as follows:

    /**
    * Rehook existing primer hero content
    *
    * @action init
    */
    function rehook_primer_hero_content() {

    remove_action( ‘primer_hero’, ‘primer_add_hero_content’ );

    /**
    * Display content in the hero element.
    *
    * @action primer_hero
    */
    add_action( ‘primer_hero’, function() {

    dynamic_sidebar( ‘hero’ );

    } );

    }
    add_action( ‘init’, ‘rehook_primer_hero_content’ );

    All the best,

    James

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter WOWTALKS

    (@wowtalks)

    P.s I put in in with another bit of mu code also so maybe the problem lies there?

    Full code here:

    <?php

    add_filter( ‘get_custom_logo’, function ( $html ) {

    $new_logo_url = ‘https://idiscover360.com/&#8217;; // <– Just change this.

    $search = sprintf( ‘<a href=”%s”‘, esc_url( home_url( ‘/’ ) ) );
    $replace = sprintf( ‘<a href=”%s”‘, esc_url( $new_logo_url ) );

    return str_replace( $search, $replace, $html );

    } );

    /**
    * Rehook existing primer hero content
    *
    * @action init
    */
    function rehook_primer_hero_content() {

    remove_action( ‘primer_hero’, ‘primer_add_hero_content’ );

    /**
    * Display content in the hero element.
    *
    * @action primer_hero
    */
    add_action( ‘primer_hero’, function() {

    dynamic_sidebar( ‘hero’ );

    } );

    }
    add_action( ‘init’, ‘rehook_primer_hero_content’ );

    Hi James,

    I’ve just tested the above code on my local install and it appears that the hero widget does display on all pages. I’m not encountering the issue you describe. If you’ve customized any of the Primer template files, that may be the issue.

    Evan

    Thread Starter WOWTALKS

    (@wowtalks)

    Ah!

    Thanks for the reply. If I have, I can’t recall what. I’ll have a look and see. I have some custom CSS for the hero. Would that be a problem?

    Best,

    The custom CSS shouldn’t be the issue unless you are specifically hiding the hero widget on pages that aren’t the homepage, but I’d imagine that would be fairly hard to do without knowing you are doing it.

    Best,
    Evan

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show Hero header widget on all pages’ is closed to new replies.