The native menu builder in WordPress might build your menu links ‘relative’ to the WordPress location if you drag and drop items from the lefthand panes to the menu itself. It will try to do that by making use of your permalinks.
Custom menu items are almost always full links.
I don’t trust either system or my memory completely so I install the Broken Link Checker plugin to double check everything and give me a warning that I can work with to then fix any broken items.
https://www.ads-software.com/plugins/broken-link-checker/
Running the Broken Link Checker at its native 72-hour settings should suffice to catch most problems fairly quickly. After three days you can throttle it back to traverse the site in 480-hours (or thereabout) and leave it running at a very small cost in performance. It is a resource hog at 72-hours but worth it for keeping your problems to a minimum.
The plugin does have a warning that it hasn’t been tested with the last three upgrades but I’ve been running it on most of my sites without a hitch and if you’re worried at all you can disable it once you’ve cured all your potential problems.
My sites have a lot of dynamic content from ‘elsewhere’ and I need to know when things like links and images break. I just let ‘er run at 480-hours myself.
I hope this helps!!!
]]>home_url()
+ the desired path. I use the WP_HOME
and WP_SITEURL
constants in wp-config.php
(which is gitignored) so home_url()
is always pointing to the right place.
add_filter('wp_nav_menu_objects', function ($menu_items) {
foreach ($menu_items as $i => $menu_item) {
$item_path = parse_url($menu_item->url, PHP_URL_PATH);
$menu_item->url = home_url() . $item_path;
$menu_items[$i] = $menu_item;
}
return $menu_items;
});
]]>