• Resolved Breat

    (@breat)


    hello,

    how can I add the right sidebar in home page ?

    I added <?php get_sidebar(); ?> in the index.php child theme but the sidebar is below the content.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there!

    get_sidebar(); will pull call the sidebar into the page, but positioning is all done by CSS.

    The CSS in Gazette isn’t built to do anything sidebar related on the homepage, so we’d need to rework a lot of that to do things like position the sidebar, set the content width, set the sidebar width, and set the widths of the columns.

    Adding sidebars to grids can be tricky ??

    This CSS should be a good starting point: https://pastebin.com/9hhLNVxM

    It keeps the same number of columns, which means they’ll be pretty narrow on some screens. Changing the column layout would have been even more complex!

    The last step will be to add the following to your child theme’s functions.php file, so the javascript for to expand the menu works on mobile devices:

    function enqueue_homepage_sidebar_toggle() {
        if ( is_home() && is_active_sidebar( 'sidebar-1' ) ) {
            wp_enqueue_script( 'gazette-sidebar', get_template_directory_uri() . '/js/sidebar.js', array(), '20150429', true );
        }
    }
    
    add_action( 'wp_enqueue_scripts', 'enqueue_homepage_sidebar_toggle' );

    Try all of that out as a starting point. If it doesn’t quite get you where you wanted, you’ll probably want to look into finding a designer to help with additional custom coding ??

    Thread Starter Breat

    (@breat)

    thank you, but how to have 2 column only ?

    Give this a try and let me know how it looks:

    @media screen and (min-width: 960px) {
    .blog .site-main .hentry {
        width: 247px;
    }
    
    .blog .site-main .hentry:nth-of-type(even) {
        margin-left: 30px;
        margin-right: 0;
        clear: none;
    }
    
    .blog .site-main .hentry:nth-of-type(odd) {
        margin-right: 30px;
        margin-left: 0;
        clear: left;
    }
    }
    
    @media screen and (min-width: 1080px) {
    .blog .site-main .hentry {
        width: 292px;
    }
    }
    
    @media screen and (min-width: 1380px) {
    .blog .site-main .hentry {
        width: 405px;
    }
    }
    Thread Starter Breat

    (@breat)

    it’s ok, thank you

    You’re welcome!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Right sidebar in home page’ is closed to new replies.