• Resolved geomouchet

    (@geomouchet)


    I trying to add a custom sidebar by following the instructions here. I added the following to my functions.php of my child theme:

    if ( function_exists ('register_sidebar')) {
        register_sidebar ('custom');
    }

    Then I created a sidebar-custom.php

    <?php
    /**
     * The custom sidebar.
     *
     * @package agua_dulce-first-child
     */
    if ( ! is_active_sidebar( 'sidebar-custom' ) ) {
    	return;
    }
    ?>
    
    <div id="secondary" class="sidebar-area" role="complementary">
    	<div class="widget-area">
    		<?php dynamic_sidebar( 'sidebar-custom' ); ?>
    	</div>
    </div><!-- #secondary -->
    ?>

    The sidebar does not show in Appearance/Widgets

Viewing 1 replies (of 1 total)
  • Thread Starter geomouchet

    (@geomouchet)

    Apparently the instructions at that link are outdated or otherwise incorrect. I found another forum question that showed this as the correct way to add a custom sidebar:

    add_action( 'widgets_init', 'theme_agua_dulce_first_child_widgets_init' );
    function theme_agua_dulce_first_child_widgets_init() {
        register_sidebar( array(
            'name' => __( 'Custom', 'theme-agua_dulce-first-child' ),
            'id' => 'sidebar-custom',
            'description' => __( 'Custom sidebar.', 'theme-slug' ),
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
    	'after_widget'  => '</li>',
    	'before_title'  => '<h2 class="widgettitle">',
    	'after_title'   => '</h2>',
        ) );
    }

    After making that change it now works.

Viewing 1 replies (of 1 total)
  • The topic ‘Adding a custom sidebar’ is closed to new replies.