Answer the question
In order to leave comments, you need to log in
How to add get_home_url() to custom menu link (WP)?
Hello.
The meaning is this. Arbitrary links can be added to the WP menu. I need the link to look like: http://site.ru/#id1
But I don't want to write down the site address. WP has a tag get_home_url()
that adds the URL of the main page. But in the control panel, where menu items are edited:
if you do this get_home_url()#id1
, then garbage comes out, because PHP is not perceived there.
The question is, how can this be implemented?
Answer the question
In order to leave comments, you need to log in
More or less like this
add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2);
function add_search_box_to_menu( $items, $args ) {
return preg_replace('/#/i', get_home_utl() . '#',$items);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question