1

I've been trying to create Page Layout's so that the person using the theme to position the sidebar either on the left, right or have the page as a full width one. I've looked at another theme and they have files called content-nosidebar.php and so on for left and right so I've gone a head and done that but something tells me I need to call some kind of function for this.

I've looked around the WordPress codex but that says something about Page Templates and like I said I'm fairly new to it so if you could help me by pointing me in the right direction that would be awesome :)

1 Answer 1

2

Add this in your functions.php

    if( !function_exists( 'my_custom_widgetize_theme' ) ){

        add_action ( 'after_setup_theme', 'my_custom_widgetize_theme', 10 );

        function my_custom_widgetize_theme(){

            register_sidebar(array(
                'name' => 'My SideBar',
                'id'   => 'my_sidebar',
                'description'   => 'This is the widgetized Side Bar.',
                'before_widget' => '<div id="%1$s" class="widget %2$s">',
                'after_widget'  => '</div>',
                'before_title'  => '<h4>',
                'after_title'   => '</h4>'
            ));

        }

}

//this will be display your side bar

<div class="col-lg-6 col-md-6 col-sm-12">
     <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('private_event')); ?>
</div>

after you add this code, you'll see your new sidebar on your dashboard widgets area, there you can drop your menus etc.. wordpress

5
  • Okay I've just realized I've already done this in my code - prntscr.com/9hkudx - but when I go to edit a page it doesn't give me the Page Layout option where I can have a full width page or a sidebar page
    – Stephen
    Dec 23, 2015 at 10:11
  • i think you need to creat defrnt tamplate for that.. Dec 23, 2015 at 10:13
  • <?php /** * Template Name: Register * ?> add this line in top of your new tamplatename-page.php Dec 23, 2015 at 10:13
  • please check this link wpbeginner.com/wp-themes/… Dec 23, 2015 at 10:17
  • Please add an explanation to your answer.
    – fuxia
    Dec 23, 2015 at 10:22

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.