
-
AuthorPosts
-
November 27, 2019 at 1:51 pm #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
ClaudiaURL and PW you find in pc
November 28, 2019 at 11:32 pm #1161127Hey claudipro,
Please check now, edited the page settings let us know if this works.
Best regards,
BasilisNovember 29, 2019 at 11:56 am #1161197Hi 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
ClaudiaDecember 3, 2019 at 11:41 am #1162144Hi,
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,
IsmaelDecember 3, 2019 at 12:11 pm #1162159Hi 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
ClaudiaDecember 3, 2019 at 3:30 pm #1162226Hi,
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,
IsmaelDecember 3, 2019 at 3:50 pm #1162241Hi 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
ClaudiaDecember 4, 2019 at 9:14 am #1162494Hi,
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,
IsmaelDecember 4, 2019 at 12:19 pm #1162544Cool! Thanks a lot Ismael.
The code you added I can find in CSS or in the child function.php?
Greetings
ClaudiaDecember 4, 2019 at 5:51 pm #1162676 -
AuthorPosts
You must be logged in to reply to this topic.