Archived topic
How to enable Secondary Navigation only on particular pages?
5 replies · Started by sumanta on March 21, 2018
Hi,
I want to enable Secondary Navigation only on particular pages not side wide? How to do that?
GP Premium version: 1.5.5. Thank you.
Hi there,
We are currently on GP 1.5.6 so I would recommend updating: https://docs.generatepress.com/article/updating-gp-premium/
As for hiding the secondary navigation, the disable element metabox should help: https://docs.generatepress.com/article/disable-elements-overview/
Thank you for your reply. But actually, I wanted to know if the secondary navigation can be disabled for a particular custom post type instead of disabling for an individual post each time we create a post (maybe programmatically?). I want to release the site for authors and it is not practically possible to ask them to disable secondary navigation every time they create a post.
Can you link me to a post where you want to disable it?
Because this is an intranet portal, I cannot share you the link as it is not accessible from outside. I would like to know whether we can disable on a particular custom post type using some php code?
Try this snippet:
add_filter( 'option_generate_secondary_nav_settings','lh_cpt_secondary_nav_location' );
function lh_cpt_secondary_nav_location( $options ) {
$post_types = array( 'post-type', 'another-post-type' );
if ( in_array( get_post_type(), $post_types ) ) {
$options[ 'secondary_nav_position_setting' ] = '';
}
return $options;
}