Replace https with http in wp_nav_menu

I want to replace all links in my main menu with http whenever they are https

I have tried the function below but it has no effect

function wp_list_pages_custom() {
   $array = array();
   $pages = wp_nav_menu( array( 
      'menu'            => 'Main Menu', 
      'menu_id'         => 'menu',  
      'echo'            => true,
      'fallback_cb'     => 'wp_page_menu',
      'before'          => '',
      'after'           => '',
      'depth'           => 0
   ));
   $pages = str_replace('https', 'http', $pages);
   echo $pages;
}

Related posts

Leave a Reply

2 comments

  1. function wp_list_pages_custom() {
    
    $array = array();
    
    $pages = wp_nav_menu( array( 
      'menu'            => 'Main Menu', 
      'menu_id'         => 'menu',  
      'echo'            => false,
      'fallback_cb'     => 'wp_page_menu',
      'before'          => '',
      'after'           => '',
      'depth'           => 0
    ));
    
    $pages = str_replace('https', 'http', $pages);
    
    echo $pages;
    
    }
    

    you had echo true, so the function handles the output