0

I added a new sidebar according to WordPress Codex and for some reason it shows only on the admin and nothing shows on my front pages..

I tried to look for it on Google and here on the forums but I couldn't find what I'm doing wrong.

I'm using Sahifa theme which has it's own "theme-functions.php". It doesn't work if i add it to the 'functions.php'.

Here is my code-

<?php
function arphabet_widgets_init() {
    register_sidebar(array(
        'name' => 'Header Widget Area',
        'id' => 'home-header-1',
        'before_widget' => '<div id="arphabet">',
    ));
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
?>

And on my 'header.php'-

<div id="header-widget">
    <?php dynamic_sidebar( 'home-header-1' ); ?>
</div>

I added a banner widget to my sidebar through the admin panel but nothing shows..

Where did I go wrong?

  • Please link to the page on the Codex you're referring to. – Brad Dalton Jul 19 '14 at 19:04
  • Thanks, that's where i looked- codex.wordpress.org/Widgetizing_Themes and i made few modifications according to what i found on google/forums – Neit Jul 19 '14 at 19:41
1

If you register a new sidebar widget area in a child theme, use this code in your child themes functions file:

register_sidebar( array(
    'name' => 'Header Widget Area',
    'id' => 'home-header-1',
    'description' => __( 'Your Widget Description.', '$text_domain' ),
) );
  • Thanks for your help Brad, i found my problem it's a little embarrassing.. I noticed in my code that the div i created for the widget isn't showing and then i found out it was on an elseif and not also on the if itself so now it works :) – Neit Jul 19 '14 at 20:49
  • No worries @Neit. Please mark this as a useful answer and/or upvote. Thanks – Brad Dalton Jul 19 '14 at 21:14

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.