S
S
Sergey Dydaevskiy2018-06-10 17:37:44
WordPress
Sergey Dydaevskiy, 2018-06-10 17:37:44

PHP, WORDPRES - How to add a slash before the anchor (/#ankor) in menu links, but not for the main page?

In general, there is a beautiful theme that is just what the doctor ordered for the landing page. And if you scroll across the page, a beautiful highlight of menu items occurs, if you scroll on the main page and scroll to the anchor block that is present in the menu. But the problem is that for this beauty, links with anchors should not be spelled with a slash, that is.
If the link is in the site.ru#uslugi menu - the highlighting magic in the menu works (but the transition to the anchor on the main page will not work if you navigate from other pages of the site :( )
If the link looks like this site.ru/#uslugi, the transition to the anchor on the main page works but the beauty of highlighting in the menu for the main page is lost....
In general, based on this, I need to understand what to write in function.php to add slashes before the anchor for all pages except the main one. Thanks to all who answered.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
La1serg, 2018-06-10
@La1serg

Crutch:
make 2 menus - one for the main page, the second for all the rest. In the first menu, for each item, specify the url with an anchor without a slash, in the second - through a slash.
Not a crutch:
highlighting is done using js. Edit the js-nick logic so that urls with slashes are highlighted and, accordingly, indicate them in the menu.

E
Eugene Chefranov, 2018-06-11
@Chefranov

In the general settings, set the address without a slash and everything will be ok.
But if I were you, I would read not from the hash, but from the data attribute of the link ( see an example on my site ). Then you would not have clogged URL
PS Strange landing. A landing page usually has one page, not several.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question