Viewing 18 posts - 1 through 18 (of 18 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()) {
    		if(get_post_type($post->ID) == 'portfolio' && 'EVENTS' == $item->post_title) {
    			$classes[] = "current-menu-item";
    		}
    		
    		if(in_array('resources', $have)) {
    			if ( 'RESOURCES' == $item->post_title ) {
    				$classes[] = "current-menu-item";
    			}
    
    			if ( 'NEWS' == $item->post_title ) {
    				$classes = array( 'menu-item', 'menu-item-type-post_type', 'menu-item-object-page' );
    			}
    		}	
    	}
    	
        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

    #1180290

    Hi Victoria,
    somehow my top navigation has a bug. I choose Events, the page opens (portfolio post shown in masonry) and Events in the navigation is aktiv (orange color). But when I open a single portfolio entry the Menu Events in the top navigation isn’t aktiv anymore.
    I hope you can help me with this problem, thank you
    Claudia

    #1180790

    Hi,

    Welcome back!

    We adjusted the above filter a bit. The Events menu item should be highlighted or activated when a single portfolio entry is viewed.

    Best regards,
    Ismael

    #1180827

    Hi Ismael,

    thank you for the fast support, it works! Did this happens because I updated the theme? But the filter is in the child theme …
    Have a nice day
    Claudia

    #1180946

    Hi,

    Glad it’s working.

    No, it’s not the update. We just didn’t implement the conditions for the portfolio or event items before.

    Best regards,
    Ismael

    #1181010

    Okay, thank you!

    #1181159

    Hi,

    Thanks for the update. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #1181226

    You can close the topic.
    Greetings
    Claudia

    #1181412

    Hi Claudia,

    Great :) We are closing the thread.

    If you need further assistance please let us know in a new one.
    Best regards,
    Victoria

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

The topic ‘Navigation, BlogPost and Masonry’ is closed to new replies.