-
AuthorPosts
-
February 21, 2019 at 11:12 pm #1070132
Hello Enfold Support.
I wish to remove the automatic main menu highlight from all “posts”. In “Theme Options” I set “Where to Display the Blog –> Blog”. I do not wish to change this. However, all posts, when clicked, will automatically highlight the “Blog” Main Menu Link. I do not want this to happen.
This does not happen to any of the other main menu links. The link will highlight at first and show an active state when someone clicks it, but they unhighlight themselves when the user clicks to direct to another page. For Example: If you click the “Destinations” Main menu link, it will highlight that tab. However, once you scroll down and click an actual destination (i.e. United Arab Emirates), it will take you to that page and no longer highlight the “Destinations” main menu link. However, if you click the “Dubai” button (after clicking the United Arab Emirates button), it will highlight the “Blog” menu link. I want it to be unhighlighted (for all “posts”) since Dubai is set as a “post” in WordPress as opposed to a “page.”
In other words, I wish to have some control over this (to have it highlighted in an active state when necessary and unhighlighted in an active state when unnecessary).
Please let me know if you need further clarification. Thank you.
Site: aceadventurer.com
February 22, 2019 at 5:44 am #1070223Hey acelam714,
The reason the “Blog” menu link is highlighted when you click a “post” is because “Blog” is a parent item, it is also the parent of the “Dubai” post.
If I understand correctly you don’t want any post to highlight “Blog”, do you want page or pot to highlight “Destinations” or any other menu items?
If changing the setting at Theme Options > Where to Display the Blog > Blog solves this why do you not want to do this?Best regards,
MikeFebruary 22, 2019 at 9:52 pm #1070486Thank you for responding, Mike.
As for not changing it, the Theme Options –> Where to Display –> Blog is currently the setting (I set it as Blog). If I do NOT set it as Blog, then it will not be the parent (and it will not highlight). However, I am afraid that might interfere with the email RSS campaign feed. Furthermore, the posts do not display correctly when Blog is NOT assigned as a parent.
Is there another way to do this? I know for sure that the “Destinations” tab is the parent to the “United Arab Emirates” page, but the Destinations tab does not get highlighted when the United Arab Emirates page is clicked. Is there any particular reason why it does not highlight in this case? I might actually prefer it if it actually highlighted in this case and not the other.
Thank you
February 23, 2019 at 6:28 am #1070575Hi,
To solve the highlighting of Destinations when on the “United Arab Emirates” page, add this css:#top #header .av-main-nav > li.current-page-ancestor > a .avia-menu-text,#top #header .av-main-nav > li.current-page-ancestor > a .avia-menu-subtext { color: #109bc5 } .avia-menu li.current-page-ancestor { background-color: #f2f3ff; border: 1px solid #ffffff!important; border-radius: 100px !important }
But to not highlight the blog menu item on all post pages we can remove the “current-menu-item” class from the menu item.
Try adding this code to the end of your functions.php file in Appearance > Editor:function remove_blog_highlighting(){ ?> <script> (function ($) { $(window).load(function() { if ($("body").hasClass("single-post")) { $("#menu-item-1115").removeClass('current-menu-item'); } else { } }); })(jQuery); <?php } add_action('wp_footer', 'remove_blog_highlighting');
Best regards,
MikeFebruary 24, 2019 at 11:02 pm #1071041Thank you, Mike. The Destination highlight works perfectly. Was there a reason why it did not work by default? I certainly set the Destination page as the parent.
The other set of code to remove the highlighting did not work, however. Is there something else?
February 25, 2019 at 1:41 pm #1071274Hi,
Glad to hear the Destination highlight works perfectly, I think the issue was that it was a parent and a ancestor, but glad it’s sorted out.
As for the script, I would need to login and see, because when testing your page it works. Perhaps when you copied it you got curly quotes.Best regards,
MikeFebruary 25, 2019 at 9:23 pm #1071470Oh, I see. It’s to be inputted into the Editor. Hmmm, I’m not sure I want to do that actually, because it seems to be fundamentally altering the theme itself.
Actually, is there a way to make it so the Dubai post appears in the “Destinations” tab as you did for the United Arab Emirates page? I think that might be simpler if we can work with the custom CSS to be inputted into the General Styling section. I understand that can be tricky since the United Arab Emirates is a page whereas Dubai is a post. I’m wondering if it is possible.
My apologies for the complications and thank you for assisting.
February 27, 2019 at 4:16 am #1072139Hi,
To have “Destinations” highlighted when on any post, instead of the “Blog” please try this css:#top.single-post .avia-menu li.current-menu-item { background-color: transparent !important; border: 0px solid #ffffff!important; border-radius: none !important; } #top.single-post #header .av-main-nav > li.current-menu-item > a .avia-menu-text, #top.single-post #header .av-main-nav > li.current-menu-item > a .avia-menu-subtext { color: #ffffff !important; } #top.single-post .avia-menu li.menu-item-mega-parent { background-color: #f2f3ff; border: 1px solid #ffffff!important; border-radius: 100px !important; } #top.single-post #header .av-main-nav > li.menu-item-mega-parent > a .avia-menu-text, #top.single-post #header .av-main-nav > li.current-menu-item > a .avia-menu-subtext { color: #109bc5 !important; }
This should also work for new post as long as you keep the same menu structure, that is we are targeting the menu-item-mega-parent instead of the current-menu-item
Best regards,
MikeFebruary 28, 2019 at 12:45 am #1072442Thank you, Mike. That code works great. Is there a way for me to change the code so that only specific posts will show up in the Destinations tabs. Understandably, not all posts will be about destinations. As in, is there a way for me to go into the Dubai post and change some setting around so it only shows up for Destinations? I was only able to assign parents for pages and not posts.
February 28, 2019 at 3:24 am #1072452Hi,
I believe the easiest way to do this is to add a category class to the posts, this way all of the posts with the same category will highlight the “destinations” menu item.
Try adding this code to the end of your functions.php file in Appearance > Editor:// add category class on single post page add_filter( 'body_class', 'add_category_class' ); function add_category_class( $classes ) { if( is_single() && has_category('destinations') ) $classes[] = 'destinations-cat'; return $classes; }
this code will add destinations-cat class to all of the posts that are in the category destinations
Then please change the highlighting css above to:#top.single-post.destinations-cat .avia-menu li.current-menu-item { background-color: transparent !important; border: 0px solid #ffffff!important; border-radius: none !important; } #top.single-post.destinations-cat #header .av-main-nav > li.current-menu-item > a .avia-menu-text, #top.single-post.destinations-cat #header .av-main-nav > li.current-menu-item > a .avia-menu-subtext { color: #ffffff !important; } #top.single-post.destinations-cat .avia-menu li.menu-item-mega-parent { background-color: #f2f3ff; border: 1px solid #ffffff!important; border-radius: 100px !important; } #top.single-post.destinations-cat #header .av-main-nav > li.menu-item-mega-parent > a .avia-menu-text, #top.single-post #header .av-main-nav > li.current-menu-item > a .avia-menu-subtext { color: #109bc5 !important; }
Best regards,
MikeFebruary 28, 2019 at 10:59 pm #1072788I added the code at the end of the functions-enfold.php file in the Editor and copied the CSS into General Styling and added the category to the post, but it doesn’t seem to be working. I pretty much copied as is. Is there something else I need to do?
// add category class on single post page
add_filter( ‘body_class’, ‘add_category_class’ );
function add_category_class( $classes ) {
if( is_single() && has_category(‘destinations’) ) $classes[] = ‘destinations-cat’;
return $classes;
}March 1, 2019 at 4:55 am #1072862Hi,
functions-enfold.php is the wrong file, please try functions.php, otherwise Please include an admin login in the Private Content area so we can take a look.Best regards,
MikeMarch 1, 2019 at 9:36 am #1072984Ah, I found it in the file manager. It was not in Appearance –> Editor for some reason. Thank you for being patient with me, Mike. Your support is great as always. Can you explain this part of the code to me? I just keep thinking it’s just white with nonexistent background and radius. That confuses me.
#top.single-post.destinations-cat .avia-menu li.current-menu-item {
background-color: transparent !important;
border: 0px solid #ffffff!important;
border-radius: none !important;
}
#top.single-post.destinations-cat #header .av-main-nav > li.current-menu-item > a .avia-menu-text, #top.single-post.destinations-cat #header .av-main-nav > li.current-menu-item > a .avia-menu-subtext {
color: #ffffff !important;
}Also, does this mean that I can add any category by reusing that function.php and CSS by simply changing the words “destinations” to something else? So if I have a menu link that says “stuff” I can start directing items to that parent page simply by adding the “stuff” category and setting the posts as such?
March 2, 2019 at 4:04 am #1073481Hi,
That is half of the css solution that I posted, it is to remove the highlighted button for the “current-menu-item” which you didn’t want highlighted. The other half of the css highlights the button you did want highlighted. But both require that the javascript part of the solution works to add the correct class.
If you change the word “destinations” it will do nothing, because it will be broken.
In order to get this to work, I need to see why the function is not working as I wrote it.Best regards,
MikeMarch 3, 2019 at 9:12 pm #1074034Oh, ok. So, I can’t simply add the same code in function.php, change “destination” to “stuff”, and add the css changing “destination” to “stuff” for a new category even for another menu link? I thought that would work since the only difference was the menu link category. Only the word changed. It’s all good though. I really do appreciate all the help.
One final question. I’ve just been putting CSS into general styling, and the change to function.php is rather important so I don’t mind changing the original parent theme for that part. When would you recommend that I use a child theme in the future?
March 3, 2019 at 9:24 pm #1074039Hi,
Using a child theme is a good idea, as you are building your site you will surely add more customizations and a child theme helps protect your customizations.Please use our pre-built child theme
You will want to take a couple of steps, 1: please export your theme settings at: Enfold Theme Options > Import/Export > Export Theme Settings File to your computer, this is just for backup.
2: Once you install your child theme, please import your parent theme settings at:
Enfold Theme Options > Import/Export > Import Settings from your Parent Theme
Then you’ll need to re-set your menu options.
Finally, sometimes it is necessary to save your theme options one more time, to encourage the settings to be saved and activated in the merged /wp-content/uploads/dynamic_avia/ folder, a simple way to do this is to go to General Styling > Quick CSS field and place a space in the field so the theme options “Save all changes” button is clickable.Best regards,
MikeMarch 4, 2019 at 4:15 am #1074118This reply has been marked as private.March 5, 2019 at 5:21 am #1074648Hi,
First please export your theme settings file, so you will have a backup.
Then install your child theme and activate it.Then when you go to the import/export options page you will find a new option to “Import Settings from your Parent Theme”
If you have any problems afterward, you can import the parent theme settings file that you saved earlier, via “Import Theme Settings File”
So, yes it’s the same process, just in this specific order.
It will save your customizations from the General Styling > Quick CSS
But your customizations in your parent functions.php, should be moved manually to your child theme functions.phpBest regards,
MikeMarch 8, 2019 at 8:12 pm #1076456Do I do that in Appearance –> Themes –> Add New –> Upload File (the child theme) to install the child theme? So, basically, just like the process for installing the Enfold theme itself. Then I go into Enfold –> Import/Export for the parent stuff right?
When I tried to install the child theme through the “Import Theme Settings File” it only lets me select the style css folder, and I don’t think that’s right.
My apologies for the confusion. Everything is already backed up as well, but I just want to confirm 100% before I do any fundamental changes like this.
March 9, 2019 at 1:34 am #1076516Hi,
I’m sorry, I think I have confused you by suggesting an extra step to make a backup of the theme settings file.
All you need to do is upload the child theme by going to Appearance –> Themes –> Add New –> Upload File
and then activate it.
Then go to your Enfold Theme Options > Import/Export > Import Settings from your Parent Theme.
If you have a backup of your site, I will be happy to do this for you, if you wish.Best regards,
MikeMarch 9, 2019 at 11:28 pm #1076848That makes sense. I got it to work. I have moved the code to the Child’s function.php file. Thank you, Mike. Your help has been exceptional.
Is my understanding of the following correct?
1) The Child Theme will allow me to change many of the files themselves (like functions.php) without affecting the parent them. It will also allow for seamless updates (since these updates will affect primarily the parent theme) without changing the settings I have in place for the Child Theme.
2) If something goes wrong with the child theme, I can simply just go into Appearance –> Theme –> Activate the old parent Enfold theme and it should be good
3) The Child Theme folder currently only have the function.php and style.css at the moment for editing (as far as I can see)March 10, 2019 at 7:00 pm #1077087Hi,
1: yes
2: it would be ok, but your customizations in the child theme would be gone. But there is no reason to think you will lose your child theme.
3: this is correct.Best regards,
MikeMarch 11, 2019 at 1:52 am #1077175Thanks for helping me with all of this, Mike.
I just have one last issue. For some reason, I can’t figure out how to change the spacing between posts on the “Blog” page. There is a rather large gap when I use the grid layout from the “Blog Post” element. For example, the top 3 posts have a huge gap with the bottom 3 posts (there are 3 posts for each row). While we’re at it, can also I get help with changing the vertical padding (between two posts on the same row).aceadventurer.com/blog/
March 12, 2019 at 4:54 am #1077622Hi,
Please try this css, it removes the bottom margin from the post slider:#top .avia-content-slider .slide-entry-wrap { margin-bottom: 0px !important; }
If you adjust the 0px to a negative number it will pull the posts even closer together.
This css reduces the margin between the posts by 50%:#top .avia-content-slider .slide-entry-wrap .slide-entry.av_one_third { margin-left: 3% !important; }
Feel free to adjust to suit.
Best regards,
MikeMarch 15, 2019 at 6:04 am #1078999Everything works as intended. Thank you.
Now you’ve got me curious haha. How does 1/3rd and 3% end up in reducing 50%? Forgive my ignorance.
March 15, 2019 at 12:50 pm #1079105Hi,
Glad to hear that it is working as intended. What I meant was the margin was 6% but the code above changes it to 3%, thus 50% less :)
Glad we were able to help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)Best regards,
Mike -
AuthorPosts
- The topic ‘Remove Highlighting from Main Menu Link for Posts’ is closed to new replies.