• Hi,
    I have a wp_nav_menu on my site, but I want to add a prefix to all pages on the site (e.g. example-home, example-contactus, etc.) but not show this prefix on the menu list. (e.g. home, contactus, ..).

    Is there anyway I can filter each menu item to only show the second part of the page name on the site?

    Any help would be appreciated.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I believe that you can use the ‘walker_nav_menu_start_el’ filter to change that. Look like it will take a little regex. The ‘the_title’ filter also runs but that runs elsewhere also.

    <?php wp_nav_menu($args); ?>
    please Pass arguments to wp_nav_menu()..
    EX : wp_nav_menu(‘link_before’=> ,’exapmle’);
    see this link

    The ‘link-before’ argument will add content before the page title. It won’t remove content from the title, which is which is what the original poster is trying to do– ie. add a prefix to the pages “but not show this prefix on the menu list”. If you add a prefix to the page title, you then need to remove that prefix from the title as the menus are generated. At least, that is how I understand the question.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_nav_menu filer out words’ is closed to new replies.