Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1160617

    Hello,
    I am using the Blogpost for the Section News, this page I choose in Theme Options as my Blogpage. All the Posts for News have the Category News. But I have also Posts with the Category Resources/Case Study/etc. This Posts are on the Page Resources and I am using Masonry with the option to select the Categories.
    The Problem is when I klick on a Resources Post and it opens the Post the top navigation is showing News as aktiv navigation, but it have to show Resources as aktiv.
    Is there a solution how I can fix this?
    Thanks a lot
    Claudia

    URL and PW you find in pc

    #1161127

    Hey claudipro,

    Please check now, edited the page settings let us know if this works.

    Best regards,
    Basilis

    #1161197

    Hi Basils,
    unfortunaly I still have the aktive News Navigation when I klick on a Post in Resources. I can send you this screenshot: https://imgur.com/eGOI8sF
    Maybe it’s easier to see the problem I have.
    Thank you
    Claudia

    #1162144

    Hi,

    Thank you for the update.

    Add this filter in the functions.php file to adjust the classes of the menu items based on the post category.

    /**
     * Filter the CSS class for a nav menu based on a condition.
     *
     * @param array  $classes The CSS classes that are applied to the menu item's
     	<li> element.
     * @param object $item    The current menu item.
     * @return array (maybe) modified nav menu class.
     */
    function wpdocs_special_nav_class( $classes, $item ) {
    	global $post;
    	$have = array();
    	$categories = get_the_category( $post->ID );
    
    	if($categories) {
    		foreach($categories as $key => $category) {
    			$have[] = $category->slug;
    		}
    	}	
    
    	if(is_single() && in_array('resources', $have)) {
    		if ( 'Resources' == $item->title ) {
    			$classes[] = "current-menu-item";
    		}
    
    		if ( 'News' == $item->title ) {
    			unset($classes['current-menu-item']);
    		}
    	}
    
        return $classes;
    }
    add_filter( 'nav_menu_css_class' , 'wpdocs_special_nav_class' , 10, 2 );
    

    This will only work for posts with the category “resources”.

    Best regards,
    Ismael

    #1162159

    Hi Ismael,
    unfortunally this is not working. The Posts for Resources all have category Resources but also some other categories for sorting. After I copy the code in the child function.php the aktiv Navi was still News when I open a Resources Post. And by the same time the event page was looks distroid, all pics was gone … The posts for Event Page coming from Portfolio Posts also in a masonry Blog. Here when opening a Post the aktiv Navigation is Event.
    Thank you
    Claudia

    #1162226

    Hi,

    Thank you for the update.

    We would like to test the snippet, but the login credentials above are invalid. Please the info carefully and make sure that the Appearance > Editor panel is accessible so that we can edit the files when necessary.

    Best regards,
    Ismael

    #1162241

    Hi Ismael,
    yes the website moved yesterday and is now visible for everybody. All infos you can find in PC.
    Until know i didn’t had a time to move all CSS snippets in the Child CSS. So please don’t be surprised that you can find a lot of snippets there …
    Thank you for helping
    Claudia

    #1162494

    Hi,

    Thank you for the update.

    We modified the code a bit. We also added another script that deactivates the “news” menu item when a resources post item is currently being viewed.

    Best regards,
    Ismael

    #1162544

    Cool! Thanks a lot Ismael.
    The code you added I can find in CSS or in the child function.php?
    Greetings
    Claudia

    #1162676

    Hi Claudia,

    It is in functions.php file in the child theme, yes.

    Glad we could help :)

    If you need further assistance please let us know.
    Best regards,
    Victoria

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.