• Hello,

    I created a custom post type, and my archives page displays all the custom posts. I would like to display the sidebar at the left at this page, and at the left of my taxonomies/categories pages.

    When I change this setting in Appearance > Customize > Blog (Archives and Single), it works on the archive blog page, but not on my custom post type.

    What can I do ?

    I tried to follow instructions here : https://docs.oceanwp.org/article/203-altering-layouts but it works only on my single custom page, and not on the archives pages.

    Thanks a lot in advance,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    You are using the correct doc but try to change the conditional tag for the archive page.
    https://codex.ww.wp.xz.cn/Conditional_Tags

    Thread Starter fannyrm

    (@fannyrm)

    Thanks for this link, it helps me !
    I use this code and I have the left sidebar on all my custom post type pages.
    Thank you very much !

    function my_post_layout_class( $class ) {

    // Alter your layout
    if ( is_singular( ‘mycpt’ ) ) {
    $class = ‘left-sidebar’;
    }
    elseif ( is_archive( ‘mycpt’ ) ) {
    $class = ‘left-sidebar’;
    }

    // Return correct class
    return $class;

    }
    add_filter( ‘ocean_post_layout_class’, ‘my_post_layout_class’, 20 );`

    Thread Starter fannyrm

    (@fannyrm)

    Hi, me again

    In fact, I wanted a left sidebar because I wanted to display my sidebar before the content on mobile, but it’s not the case. And when I select the checkbox to display in first sidebar in Appearance > Customize > Blog, it doesn’t work. Do you know how is it possible to change the order on mobile ? Thanks !

    Hello,

    Kindly share that page URL where you getting that sidebar order issue.

    and for the left sidebar on the CPT, kindly try the below-snipped code and check.

    function my_post_layout_class( $class ) {
    
    	// Alter your layout
    	if ( is_single( 'mycpt' ) ) {
    		$class = 'left-sidebar';
    	}
    
    	// Return correct class
    	return $class;
    
    }
    add_filter( 'ocean_post_layout_class', 'my_post_layout_class', 20 );
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom post type and sidebar’ is closed to new replies.