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;
}
you had echo true, so the function handles the output
According to the documentation of wp_nav_menu, the echo parameter needs to be false in order to get the menu just returned instead of printed. So currently you probably have the menu printed twice. You should also check whether the method returns absolute URLs or relative URLs.