0

I want to use absolute URLs when creating custom menu links for my WordPress menu, but when WordPress renders the menu it removes the domain from the href data and simply renders them links as relative URLs.

For example, I have a custom link in a menu that is https://www.domain.com/about/. When this menu is rendered on the site, the link href has https://www.domain.com/ stripped from it setting the href to about/.

My guess is that WordPress is doing this, because the domain in the absolute URL for the custom menu item matches the site URL of the WordPress installation. I'd like for it to not do this and just render the href data as the absolute URL.

I've looked through various WordPress menu related actions and filters, but cannot seem to find anything that allows me to override this before or make a final check and correction to the href data prior to it being rendered as HTML.

Any pointers or suggestions on how to do this would be greatly appreciated!

2
  • 1
    Default WordPress doesn't do this, verify it's not theme or plugin related.
    – Milo
    Sep 8, 2017 at 19:44
  • Bingo, was WP-HTML-Compression that someone recently added to an install without letting anyone know. Sep 11, 2017 at 4:28

1 Answer 1

0

As Milo already pointed out in a comment above, Wordpress does not do that by default, so your problem should be related to your theme or one of the plugins you are using.

Before troubleshooting the problem, make sure you do a full WP backup, just to make sure you can revert to the working condition if something goes wrong.

To troubleshoot the problem, you need to activate a default WP theme (eg Twenty Seventeen). If that solves the problem, then the theme you are using is causing the problem.

If your theme passes the test, keep the default WP theme for now and then deactivate all your plugins. With your default WP theme and no plugin active, you should see the full URLs (if not, somebody modified the WP core files - that's never a good idea). Then, start re-activating the plugins, one by one, and see which plugin is the one causing your problem.

For a more general guide on troubleshooting WP, you could read this article: Beginner’s Guide to Troubleshooting WordPress Errors (Step by Step).

1
  • WP-HTML-Compression was the culprit. Thanks! Sep 11, 2017 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.