Site logo

Archived topic

removing sidebars from custom post types

9 replies · Started by kate on December 6, 2017

Viewing posts 1–10 of 10

I am new to filters and am hoping you can help me adjust this code before I add to php. Using GP 2.0.

I intend to remove sidebars from 4 custom post types.

add_filter( 'generate_sidebar_layout','​​km_custom_post_sidebar_layout' );
function km_custom_post_sidebar_layout( $layout )
$post_type = get_post_type( $post_id );
if $post_type is ​'​​​sfwd-courses​'​, ​'​sfwd-lessons​'​, ​'​sfwd-quiz​'​ or ​'​sfwd-certificates​'​;
return 'no-sidebar';
// Or else, set the regular layout
return $layout;

Hi Kate,

Give this a shot:

add_filter( 'generate_sidebar_layout', 'km_custom_post_sidebar_layout' );
function km_custom_post_sidebar_layout( $layout ) {
    $post_types = array( 'sfwd-courses', '​sfwd-lessons', 'sfwd-quiz', 'sfwd-certificates' );

    if ( in_array( get_post_type(), $post_types ) ) {
        return 'no-sidebar';
    }

    return $layout;
}

thanks for that. I thought I needed array, but I wasn't sure how to use. Great little mouse in your photo!

You're welcome!

Haha thanks! If only she was still so little.

Ah yes, you water them, they grow.

Thanks that worked and also thanks for the code snippet recommendation. That makes me less nervous.

side note: since I'm using 2.0, is the GPP plugin also still necessary or are you moving away from that?

GP Premium extends GeneratePress with premium modules, so it will always be necessary :)

got it, thanks

No problem! :)

Hello Tom!

I am having the same issue, but in LifterLMS, and intend to get rid of the side bar in quizes. Could you help? Thanks. :)

Hi there,

This thread is quite old.

Can you open a new topic for your question?

Thanks!

This archived topic is closed to new replies.