0

I have an issue wherein i have a plugin (newsletter) which has a widget whereby users can (usually) subscribe to a newsletter and other functionality.

But i digress.

I have been trying to create my own wordpress template solely for personal-use. The following is the code I've accumulated in progression to having a functional sidebar, but so far, un-successful. Any help is much appreciated. Thanks

index.php

<div id="content" class="alignCenter">  
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>  
    <?php the_content(); ?>  
    <?php endwhile; endif; ?> 
</div>  

<?php get_sidebar(); ?>

functions.php

<?php /**  * Register our sidebars and widgetized areas.  *  */
 function arphabet_widgets_init() {

    register_sidebar( array(        'name' => 'Home right sidebar',         'id' =>
 'home_right_1',

    'before_widget' => '<div>',
        'after_widget' => '</div>',
        'before_title' => '<h2 class="rounded">',
        'after_title' => '</h2>',
    ) );
    }
    add_action( 'widgets_init', 'arphabet_widgets_init' );
    ?>

Sidebar.php (taken from twentyfourtine theme )

<?php
/**
 * The Sidebar containing the main widget area
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */
?>
<div id="secondary">
    <?php
        $description = get_bloginfo( 'description', 'display' );
        if ( ! empty ( $description ) ) :
    ?>
    <h2 class="site-description"><?php echo esc_html( $description ); ?></h2>
    <?php endif; ?>

    <?php if ( has_nav_menu( 'secondary' ) ) : ?>
    <nav role="navigation" class="navigation site-navigation secondary-navigation">
        <?php wp_nav_menu( array( 'theme_location' => 'secondary' ) ); ?>
    </nav>
    <?php endif; ?>

    <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
    <div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
        <?php dynamic_sidebar( 'sidebar-1' ); ?>
    </div><!-- #primary-sidebar -->
    <?php endif; ?>
</div><!-- #secondary -->
0

When you use is_active_sidebar and dynamic_sidebar the argument needs to match the id of a registered sidebar in your theme. In your case that is going to be home_right_1 not sidebar-1 as in the code you copied.

Technically, the sidebar name should also work in both and the sidebar index number should work with is_active_sidebar but I vaguely recall having trouble getting the name to work correctly, so be aware.

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.