• hi,
    i am trying to add a widget on my homepage but its not working.i tried couple times to rewrite it but nothing happens, this is what i m writting in functions.php file

    register_sidebars( 1,
    array(
    'name' => 'Left Sidebar',
    'before_widget' => '<div id="%1$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3>',
    'after_title' => '</h3>'
    )
    );

    and on home.php
    `if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘Left Sidebar’) ) :
    endif;
    I removed the <?php ?> tagts for any disturbance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Is that all the code from the home page?

    you are checking it the negative sense and then doing nothing, do something more like…

    if (function_exists('dynamic_sidebar')) {
    dynamic_sidebar( 'Left Sidebar' );
    }

    @lee@digitalacorn: Sorry but that’s rubbish. See widgetizing themes.

    @emaarkhan: Have a look at https://quirm.net/2011/09/15/widgetizing-any-page/ Perhaps there’s something in there that will help you.

    Hello
    Have you tried to change theme?
    Same problem had happened with me. I changed theme every thing was OK.
    Wish you luck.

    @esmi – what part of it is rubbish?

    Bit rude seeing as it works perfectly… hadn’t done before I wrote it but just tested it.

    Thread Starter emaarkhan

    (@emaarkhan)

    @esmi the link u told me had this code as final

    <?php
    get_header();?>
    <div id="page">
    <?php if ( is_active_sidebar( custom'  ) :?>
    <div class="widget-area">
    <?php dynamic_sidebar( 'custom' ); ?>
    </div>
    <?php endif;?>
    <?php get_template_part( 'loop', 'page' );?>
    </div>
    <?php get_sidebar();
    get_footer();

    and it gives me error on <?php if ( is_active_sidebar( custom’ ) :?> shouldnt it be wrapped in ‘custom’?

    It’s rubbish because it depends upon what you’re trying to do. The code used was perfectly valid. Did you see the page at the link I posted?

    @emaarkhan: Yes – it should be <?php if ( is_active_sidebar( 'custom' ) :?>. I’ll go and correct that in the article.

    Thread Starter emaarkhan

    (@emaarkhan)

    Thanks esmi, i followed the tutorial for widgetizing the theme and it worked. there was a ) bracket missing in
    <?php if ( is_active_sidebar( ‘custom’ ) :?> (i thought to share it with you as i myself is new to php)
    Also the parameters in register_sidebars is 1, i am supposing it says only 1 sidebar, but what if i want more widgets with different name. should i write the same function again with unique id and name or what?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘widget not showing up’ is closed to new replies.