M
M
mrWan2018-02-05 16:07:20
WordPress
mrWan, 2018-02-05 16:07:20

Created my own menu in wordpress. There were questions with the active menu item. How can I make the item current by default?

The menu is formed from my created pages. A class is added to the menu items that makes the item active only if we are on the desired page, everything works fine when I have in the url for example ......./glavnaya (this is my main created page), but the main menu item is not highlighted when the address is without postfixes (www.site.ru). How can I make the "HOME" item active by default when the address is site.ru. and not site.ru/glavnaya?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Vorotnev, 2018-02-05
@mrWan

for example ......./glavnaya (this is my main created page)

This is wrong for you. Assign this page as the "main" page in the Reading settings.

M
mrWan, 2018-02-05
@mrWan

so far done with jquery:

if (!$('.menu-item').is('.current-menu-item')) {
     $(".menu-item:first-child").addClass("current-menu-item");
  }

If there's no other option, I'll probably leave it that way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question