I am running multisite for 5 sites. I have a theme where it doesn't have a text area at the top of the page but i want to put some introduction text on the homepage. I currently have all 5 sites using the same child theme to maintain the same look and layout.

What is the best way to add the custom text to the homepage for each site based on the domain? Would I do this somehow editing the child theme file(s) with a shortcode and functions.php?

I am a developer but pretty new to wordpress. A simple code example would be very helpful.

Bonus points and kudos if there is a way to make this a widget that can be edited in the admin so I can change the text outside of the code.


The best solution is to add a widget area that all sites have access to use and then add a text widget.

How I handled this since I had one child theme being used was I added a functions.php file and copied a duplicate of the index.php from the parent theme file into the child theme folder.

My base steps were the same as in the solution @toscho posted: https://wordpress.stackexchange.com/a/76975/35677

This made a widgetable area across all the sites and this is what I wanted. An additional note though is to have my widget use the css and custom widgets of the theme i was using took a bit of manipulation. My theme included custom widgets ontop of the defaults with special formatting for the "title" of a widget a "line break" and then the widget "content".

In my case I was able to get it to act like the themes native widgets with something like:

function welcome() {
    register_sidebar( array(
        'name' => 'Welcome Message',
        'id' => 'welcome',
        'before_widget' => '<div class="widget-top">',
        'after_widget' => '</div>',
        'before_title' => '<h4>',
        'after_title' => '</h4><div class="stripe-line"></div></div><div class="widget-container">',
    ) );
add_action('widgets_init', 'welcome');

As you can see I had to do some custom tag ending to get it to work the same.


I wouldn't do it that way when you can hook it in from your child themes functions file and use conditional tags for more control.

function wpsites_register_home_text_widget() {

register_sidebar( array(
'name' => 'Home Text Widget',
'id' => 'home-widget',
'before_widget' => '<div>',
'after_widget' => '</div>',
) );

add_action( 'widgets_init', 'wpsites_register_home_text_widget' );

add_filter( 'loop_start', 'wpsites_home_text_widget' );

function wpsites_home_text_widget() {

    if ( is_front_page() && is_active_sidebar( 'home-widget' ) ) { 
    dynamic_sidebar('home-widget', array(
    'before' => '<div class="home-widget">',
    'after' => '</div>',
) );



You can use any hook or conditional tag with this code. WordPress or theme specific hooks all work with this code.

  • Ok I kind of see what you are doing here, but how does it work? Seems like you would need to specify where in the page you want the content? Sorry trying to learn best practices here, and new to this so explanations are $$$ :-) – Shawn Jan 2 '14 at 18:29
  • You can use any hook. Depends on your theme but the question didn't supply that info and just states top of page. If you're using a theme like Genesis, then you have use of many hook positions. What theme are you using and does it include hooks? – Brad Dalton Jan 2 '14 at 18:31
  • I am using a theme that does not have any custom hooks listed in the documentation for it. Even so, I like your example there. Would there be a way to tell it where to put the content dynamically? If say I want it below certain elements on the page? If I can prevent needing to have that copy of index.php from the parent then updates to the theme will probably go alot smoother. As far as frameworks I plan on using pagelines in the near future and making my own theme. – Shawn Jan 2 '14 at 18:41
  • Yes but depends on the theme as to how easy or hard it is to modify. With Genesis you simply change the hook so its incredibly easy genesistutorials.com/visual-hook-guide – Brad Dalton Jan 2 '14 at 18:45
  • I see what you mean. That is pretty sweet. I would assume my theme has hooks in the background as you can turn certain banners on and off for example. I could probably look in there. As far as is_front_page() && is_active_sidebar() should I add those to my code? Is there a negative to not having them? What could happen? – Shawn Jan 2 '14 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.