-
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()) { 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,
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 #1162676Hi 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,
VictoriaJanuary 31, 2020 at 4:44 pm #1180290Hi 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
ClaudiaFebruary 3, 2020 at 5:07 am #1180790Hi,
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,
IsmaelFebruary 3, 2020 at 11:15 am #1180827Hi 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
ClaudiaFebruary 3, 2020 at 3:16 pm #1180946Hi,
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,
IsmaelFebruary 3, 2020 at 6:50 pm #1181010Okay, thank you!
February 4, 2020 at 6:14 am #1181159Hi,
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,
RikardFebruary 4, 2020 at 11:45 am #1181226You can close the topic.
Greetings
ClaudiaFebruary 4, 2020 at 5:57 pm #1181412Hi Claudia,
Great :) We are closing the thread.
If you need further assistance please let us know in a new one.
Best regards,
Victoria -
AuthorPosts
- The topic ‘Navigation, BlogPost and Masonry’ is closed to new replies.