Change Permalinks to Anchor Links When Using Bootstrap Navwalker

I’m currently using the Bootstrap Navwalker for a menu on a one-page theme that I’m building.

At the moment, this is generating full urls

Read More
 http://www.fulladdress.com/pagename

when I’d only like it to create

 #pagename

I’m wondering whether I need to adjust wp_bootstrap_navwalker, or if theres something I can append to wp_nav_menu.

Any help appreciated!

Related posts

1 comment

  1. I managed to find a solution to this by changing the following (line 90) in the wp_bootstrap_navwalker file

    $atts['href'] = ! empty( $item->url ) ? $item->url : '';
    

    to…

    $atts['href'] = ! empty( $item->url ) ? '#' . $item->title : '';
    

    which makes permalink take the page title instead of the url.

    Then made sure that each section of my theme had an id= that referenced its own title:

     <section id="<?php
        $pagename=excerpt;
        $post = get_post($id);
        $title = apply_filters('the_title', $post->post_title);
        echo $title;
        ?>">
    

    I’m sure there are better solutions out there, though! Eager to hear.

Comments are closed.