Remove current_page_parent from Search and 404 (3 posts)

  1. cokeyblokey
    Posted 3 years ago #

    I want to stop my Blog menu item being highlighted when Search Results or a 404 is displayed. I've googled and searched here too but the only solution I have found doesn't work for me:

    function noCurrentNavInSearch( $content ) {
    	if ( is_search() ) $content = preg_replace( '/ current_page[_a-z]*([\" ])/', '\1', $content );
    	if ( is_404() ) $content = preg_replace( '/ current_page[_a-z]*([\" ])/', '\1', $content );
    	return $content;
    add_filter( 'wp_list_pages', 'noCurrentNavInSearch' );

    Can any one give me a function that will work with the latest versions of WP?

  2. webinzicht
    Posted 3 years ago #

    The code suggested in the post below could be a work-around. I added a case and menu-item '' (empty) and the search page stops highlighting the blog (or anything).

    Why does Blog become current_page_parent with Custom Post Type?

  3. dtbaker
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic