Archived topic
set theme option by page , slug etc.
3 replies · Started by sg on June 12, 2018
Hi there,
i am using other plugin to create custom post types. whenever i edit the page, the theme option setings such as sidebar[no sidebar ] and page title [hide] BACK to default value.
i am sure there is way to fix this . force setting it to fix a value.?
sample url such as /directory/business , /directory/business/details etc
Hi there,
you can use some filters to do this, first Sidebars:
add_filter( 'generate_sidebar_layout', 'gp_custom_post_sidebar_layout' );
function gp_custom_post_sidebar_layout( $layout ) {
$post_types = array( 'slug-1', 'slug-2', 'slug-3' );
if ( in_array( get_post_type(), $post_types ) ) {
return 'no-sidebar';
}
return $layout;
}
And we can try this for the title:
add_filter( 'generate_show_title','gp_cpt_remove_title' );
function gp_cpt_remove_title( $title ) {
$post_types = array( 'slug-1', 'slug-2', 'slug-3' );
if ( in_array( get_post_type(), $post_types ) ) {
return false;
}
return $title;
}
Let me know
thanks.
You're welcome. Glad to be of help