1

I am currently building out a big site with a lot of content right now and am struggling with an aspect of internal linking. I had assumed I'd find lots of people with the same issue, however as I can't easily find a plugin to do what I need, It seems not!

A simple example is with a contact us page. I've given it the URL slug /contact-us/. When I link to this page from elsewhere in the content the link is hard coded into that content.

If I then decide I want to be a little more trendy and change the URL slug for the page to /reach-out/ I am then left with a bunch of 404 errors throughout the site. I understand that I can use a 301 redirect manager to handle part of this which is in place, however it seems pretty poor practice to have links within your own site that are 301 redirected to the correct location.

I don't know if this affects things today, however who knows what will become an issue in the future. One thing is for sure - if this were ever to be looked at, current, correct and valid links will be better than 301 redirects!

What I'd like to be able to do is when inserting a link, have the href of the link stored in the database as [{%page_id%}] (or similar pseudo-code). When the content is pulled from the database the correct URL is then inserted into the HTML that's served to the client.

This would mean that every time the URL slug or page hierarchy is changed, as far as end users (and Search Engines) are concerned the URL will have been updated.

Obviously this won't get rid of 301 redirects completely and if a URL slug is changed the 301 redirect manager will still be required to manage sites linking into this one. It will however ensure all the links on my site are kept up to date.

  • Use core features. In navigation menus, select the page item in Appearance > Menus - it's link will update dynamically to reflect the proper permalink. In template files or custom shortcodes/functions, use functions like get_permalink() or get_page_link() to display the link - it too will return the proper link. See this Codex page for other possibilities. If you need to link in post content, create a shortcode or check out some other possible solutions – bosco Apr 5 '17 at 23:16
  • I understand how to use the menus and have no problem with that - working fine. What I need to achieve is similar functionality throughout links within content. It sounds like I need to have some sort of shortcode such as [link=x] where x is the id number of the page. This brings up a few further questions: a) how do I create this so it replaces it with the correct current link for the site? b) how do I change the WYSIWYG editor linking tool to make internal linking simple? c) how do I do this so that when WordPress is updated it doesn't all break? – MGMidget Apr 5 '17 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.