Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Tim Brugman on "Adding links to internal pages by id"

$
0
0

Hi. This is my first discussion thread on WordPress functionality so let me know if this is not the right place or if I'm doing something wrong.

The other day I ran one of those online website optimizer tools on a client site of mine. One of the problems that came up was that the client filled the site with content on its staging platform and thus inside the body he had created permalinks to the staging site. When we launched the site I copied the database and taa-daa, the live site was linking to staging. Simple problem.

Plugins
Now there's plenty of plugins that can provide a solution. All of them create a shortcode, and most add a button to TinyMCE or some other new UI element so the user doesn't have to look up the id and post type of the post they want to link to and can link anything they want.

Pros: It works.
Cons: None of them add the UI to the existing 'insert/edit link' interface. That means I have to explicitly tell my client how to use it, and he has to remember to tell any and every moderator he adds. Or I have to remove the default TinyMCE buttons so there can be no confusion. Side question: Can the 'insert/edit link' window be modified with hooks?

Index.php
The documentation provides a solution as well. We could link to index.php?p=6 or index.php?cat=7 or index.php?page_id=42 etc. I assume this also works with post types.

Pros: It works. No plugins needed.
Cons: There is no interface to make this easy for the user. A plugin would have to be made. The links also get published, so yes they work - but Google wont get to index your pretty permalinks.

Add it to core?
This I have no experience with. I couldn't find any places where this might have already been discussed in the past.

Arguments for:
I think it would be a good change to the way links work. Divide the interface into internal and external right away, when the user chooses internal the interface will generate a shortcode with the chosen target's id and post type. This would also require the core to process this shortcode by default, similar to the more-tag.
A posts' id and type are the only things that will always remain the same. It would make sense to use those to connect pages together instead of hoping nobody will change a linked posts' slug.

Arguments against:
When we change all internal links in post bodies with shortcodes it will undoubtedly require some extra queries so turn those into permalinks before spitting it out on the front end. Maybe this is not lean enough for core.
Only a small portion of WordPress users will be working with different environments. My reason for wanting this is maybe not big enough for a core addition.
This feature could also help when you change the base URL of your website. This should however also happen rarely so they same 'not enough demand' argument applies.

So those are my 2c on this tiny but integral subject. To summarize: Linking internally by id seems better to me. The existing plugins are not perfect. I don't know if a perfect plugin can be made for this and I don't know if this is a change worthy of suggesting for core.

I'd love to hear what you think.


Viewing all articles
Browse latest Browse all 8245

Trending Articles