Layout of posts page- side bar just on the blog page and can I add text box above my posts?

HI I wanted to have a side bar just on the blog page. I see the global setting for side bar but I don’t see where to set for only my blog homepage (resources is the page name). Did the setting move?

Also I was trying to add a container with a text box above my automatically generated posts page.
Is the only way to do this is with a child theme?

Hi,

To achieve that, you can add the code below in your child theme’s functions.php file


/* ADD SIDEBAR TO BLOG PAGE */
function add_sidebar_blog($layout){
    if(is_home()){
        $layout = "content-sidebar";;
    }
    return $layout 
}

add_filter('x_option_x_layout_content', 'add_sidebar_blog',999);


/* ADD TEXT ON TOP OF BLOG PAGE */
function add_mytext() {
    if(is_home()) {  ?>
        <div class="mytext">
               ADD YOUR TEXT HERE
        </div>
        <?php
    }
}
add_action( 'x_after_view_global__slider-below', 'add_mytext', 10 );

Hope that helps

HI I added a child theme and edited the function.php file to add the side bar code and a scripts from another issuesbut I’m getting this error see screenshot on the sidebar code.

Hi,

Sorry, there is a missing semicolon and you forgot to include this line.

add_filter('x_option_x_layout_content', 'add_sidebar_blog',999);

Code should be


/* ADD SIDEBAR TO BLOG PAGE */
function add_sidebar_blog($layout){
    if(is_home()){
        $layout = "content-sidebar";
    }
    return $layout;
}
add_filter('x_option_x_layout_content', 'add_sidebar_blog',999);


/* ADD TEXT ON TOP OF BLOG PAGE */
function add_mytext() {
    if(is_home()) {  ?>
        <div class="mytext">
               ADD YOUR TEXT HERE
        </div>
        <?php
    }
}
add_action( 'x_after_view_global__slider-below', 'add_mytext', 10 );

Thanks

thanks the code worked

Hi there,

Please try:

/* ADD SIDEBAR TO BLOG PAGE */
function add_sidebar_blog($layout){
    if(is_home()){
        $layout = "content-sidebar";
    }
    return $layout; 
}

add_filter('x_option_x_layout_content', 'add_sidebar_blog',999);


/* ADD TEXT ON TOP OF BLOG PAGE */
function add_mytext() {
    if(is_home()) {  ?>
        <div class="mytext">
               ADD YOUR TEXT HERE
        </div>
        <?php
    }
}
add_action( 'x_after_view_global__slider-below', 'add_mytext', 10 );

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.