Put Welcome Message Widget on All Posts

Community Forums Forums Design Tips and Tricks Put Welcome Message Widget on All Posts

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  Tony 6 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #89041

    Tony
    Participant
    Post count: 5

    How do I make it so that the welcome message widget displays on all pages? Right now it only displays on the home page.

    I tried adding || is_single to the following code in my functions.php file, but it didn’t work. Can anyone help?

    //* Hook welcome message widget area before content
    add_action( 'genesis_before_loop', 'beautiful_welcome_message' );
    function beautiful_welcome_message() {
    
    	if ( ! is_front_page() || get_query_var( 'paged' ) >= 2)
    		return;
    
    	genesis_widget_area( 'welcome-message', array(
    		'before' => '<div class="welcome-message" class="widget-area">',
    		'after'  => '</div>',
    	) );
    
    }
    #89072

    nutsandbolts
    Moderator
    Post count: 3128

    It should work like this:

    //* Hook welcome message widget area before content
    add_action( 'genesis_before_loop', 'beautiful_welcome_message' );
    function beautiful_welcome_message() {
    	genesis_widget_area( 'welcome-message', array(
    		'before' => '<div class="welcome-message" class="widget-area">',
    		'after'  => '</div>',
    	) );
    
    }

    The conditional in your snippet above is saying “if we aren’t on the homepage, don’t show the widget area.” So by removing it, it should show on every single page of the site.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #89124

    Tony
    Participant
    Post count: 5

    I see. I saw the “is not” statement, but I couldn’t figure out what they were doing. Since I don’t want it on pages, I made the code like this:

    //* Hook welcome message widget area before content
    add_action( 'genesis_before_loop', 'beautiful_welcome_message' );
    function beautiful_welcome_message() {
    
    	if (  is_front_page() || get_query_var( 'paged' ) >= 2 || is_single())
    		
    
    	genesis_widget_area( 'welcome-message', array(
    		'before' => '<div class="welcome-message" class="widget-area">',
    		'after'  => '</div>',
    	) );
    
    }

    Thanks for the help!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.