Site logo

Archived topic

Remove secondary nav using hooks

3 replies · Started by Anthony on August 1, 2017

Viewing posts 1–4 of 4

Hi,

I'd like to remove the secondary nav on all pages except posts but I don't want to hide it using css rules, as explained in previous posts.

I prefer to not output it at all. How can I do it using hooks?

Thank you

You should be able to do something like this:

add_filter( 'option_generate_secondary_nav_settings','tu_dynamic_secondary_nav' );
function tu_dynamic_secondary_nav( $options ) {
	
	if ( ! is_singular( 'post' ) ) {
		$options[ 'secondary_nav_position_setting' ] = '';
	}
	
	return $options;
}

Let me know :)

Perfect it works. Thank you.

Is there somewhere more information on all these options? I've found the hooks and filters documentation pages to be not exhaustive.

This is actually a core WordPress filter which allows you to filter into any option - super useful. I'll work on adding some docs for it :)

This archived topic is closed to new replies.