I made a custom menu item on my website named Toys and linked it with 'custom links' to: http://mydomain.com/toys/our-toys/
When I go to the website the menu item Toys gets a current menu item with a green background color (as it is supposed to be). On this page you can navigate to another page, because I limited the products with 6 items every page. When I click on the next or last page button, I go to: http://mydomain.com/toys/our-toys/page/2/. On this page, the current menu item has disappeared.
Does anyone know how to set the current page items when I go to the next and previous pages? I use wp ecommerce with mazine theme.
Wordpress automatically adds a .current-menu-item class to the li of your current menu item, check that that is the class that is being styled and not a custom class or pseudo element.
e.g.
.nav .current-menu-item a {
color:red;
}
Related
I am using Wordpress and the Underscores starter theme to build a website for a client. The landing page is a one-pager with a navigation menu that slides to the correct section with anchor tags.
The issue is that for the first section the navigation link's "current" class doen't activate until I click the "home" link itself (the page doesn't move, only the class activates) or scroll a bit down. In the html the "home" section seems on the top of the viewport, so it should be activated on landing. Any ideas?
You can add current class when page is loaded
$('.main-menu li:first-child').addClass('current');
Or event check if there is no selected items:
if ($('.main-menu .current').length == 0)
$('.main-menu li:first-child').addClass('current');
You can trigger that with js jquery, somehting like
$('.yourFirstMenuElement').click();
I'm having an issue with anchor links in my menu.
Here is a quick example of the issue I'm having:
The 2 Anchor Links:
<div id="anchor1"></div>
<div id="anchor2"></div>
The Menu:
Menu Item One (http://test.com/m1)
-Sub Menu Item One (/m1/#anchor1)
-Sub Menu Item Two (#anchor2)
Essentially Sub Menu Item One will bring me to the right place but it always re loads the page if I'm currently on it.
Sub Menu Item Two works perfectly if I'm on the page but does not work if I'm on another page.
So what I need is for the link to take me to the anchor location without refreshing the page if I'm currently on it and to take me to the anchor location if I'm on a different page.
Any ideas?
Did you use full path in href on Sub Menu Item One? Add full path with the anchor in the end and it should work like you hoped.
First visit http://velnikolic.com/music/?page_id=6#test
Then hover over the music tab on the navigation. There is a highlight on both "Classic and Category 2". I think the reason for this is because they both link to anchor tags on the Music page. Is there a way to highlight only the item clicked on. For example if I clicked "Classic" only Classic and Music would be highlighted not all three.
one Idea is that u can remove ".current-menu-item" on the rest submenu items,
and only make sure you assign ".current-menu-item" to the one u cliked
when u click on one of the submenu "li".
I'd appreciate some direction on how to accomplish something with my WordPress menu. I've Googled this for hours without avail. I was to automatically insert a parent link into it's immediate submenu ul. For example, normal output is this:
Parent Menu Item 1
Parent Menu Item 2
--Submenu Item 1
--Submenu Item 2
Parent Menu Item 3
I'm looking for this:
Parent Menu Item 1
Parent Menu Item 2
--Parent Menu Item 2
--Submenu Item 1
--Submenu Item 2
Parent Menu Item 3
I don't think wp_nav_menu() has a setting for this. Rewriting the entire menu rendering function would likely be very arduous.
One workaround would be to have "Parent Menu Item 2" as an actual first child page underneath the parent page of "Parent Menu Item 2", and use the code in this SO question:
wordpress: click on Parentpage Redirect on first child page programmaticaly
to automatically redirect to it. That would, however, change the behaviour on all pages: if you open a page that has children, you will always be automatically redirected to the first child.
I'm attempting to implement a multi-level drop-down navigation menu in CSS only but there's one small part which I just can't seem to get working correctly.
What should happen is:
1) When hovering over a menu item, it should be highlighted by using a different image (this works fine).
2) When hovering over a sub-menu item, the parent menu item should be highlighted.
Point 2 works fine up until I have a class .bottom on the parent menu item (this class is used as the image is slightly different). If the parent menu item has class .bottom, the highlight simply doesn't happen.
A demo of this can be viewed here: http://jsfiddle.net/cZFtW/2/
The demo shows that when hovering over Menu 1 > Sub Menu 3 > Sub Sub Menu X, Sub Menu 3 is highlighted. However, when hovering over Menu 2 > Sub Menu 3 > Sub Sub Menu X there is no highlight.
Can anyone see what I'm missing? On a side note, there's no real reason for not using Javascript here, I'd just prefer to have it all handled by CSS if possible (only need to support IE7+).
TL;DR; version: this fiddle shows the answer.
I understand what you mean. And I am pretty sure that the styling to which you need an answer to, which works for all except for the one at the bottom, has arisen purely by accident. (Kind a nice one I must say). I am almost certain of this, because your code as well as the file names lack any form of consistancy. There is double code, there is superfluous code, and there are images missing.
Therefore I have rewritten your markup and style sheet, and came to the fiddle as mentioned above.
Now, how does it work?
The trick is to attach the background image to an element inside the list item. In this case I chose for an anchor element, since that is most the likely. The first step is to change the background image at hovering the anchor, that's basic.
The second step is to change the background again when you hover over the submenu. At that point, the anchor element isn't hovered any more, but the list item is. So you can still change the background of the anchor element.
Note: in my solution there is a small difference to what you wish: when you hover the arrow, the background if the list item is already changed instead of until the cursor is over the submenu. If you want to prevent that, then you have to add an extra element for every sub menu like you had done yourself. But I think this is pretty nice also.