0

I am new to wordpress coding. I want to add a sidebar to pages other than the home page, both pages are my custom templates. I want to list in admin so that admin can edit the content of sidebar.

Also, do I need to create widget to display every side bar?

2
  • There are many good tutorials on the internet about this subject, also a lot of questions on this site. You can also start by looking at the codex on how to register sidebars and creating custom widgets. Thank you Commented Jul 31, 2014 at 9:48
  • thank you for your reply, i have just added a side bar any how, but i need to add some list(like module 1, module 2) in it, how would i do that.
    – Racheal
    Commented Jul 31, 2014 at 10:00

1 Answer 1

0

This question has been answered many times already on this site.

There's 2 simple steps:

One: Add to functions file

register_sidebar( array(
    'name'         => __( 'Your Sidebar' ),
    'id'           => 'wpsites-sidebar',
    'description'  => __( 'Your Sidebar Description.' ),
    'before_title' => '<h1>',
    'after_title'  => '</h1>',
) );

Two: Add where you want to output sidebar

<?php if ( is_active_sidebar( 'wpsites-sidebar' ) ) : ?>
    <ul class="wpsites-sidebar">
        <?php dynamic_sidebar( 'wpsites-sidebar' ); ?>
    </ul>
<?php endif; ?>

For further learning, look in the Twenty Fourteen default theme to see how its done.

register_sidebar dynamic_sidebar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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