BLOG

Sometimes nerdy and wordy, but mostly helpful articles on website design and development.

Fixing old or unused WordPress shortcodes

| 0 Comments | WordPress

Love them or hate them, WordPress shortcodes are very popular, especially with premium WordPress themes. If you’ve ever changed themes you may have run into the issue of a shortcode no longer working. This should help you fix and or better prepare next time you update your website.

What is a shortcode?

A shortcode is a WordPress-specific code that lets you do a certain task with very little effort. Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line. We often make custom WordPress themes for clients that allow a client to easily display FAQs, team member information, tables, etc.

Are shortcodes bad?

No, but, they should be created by developers with future-proofing in mind. Unfortunately, this is not always the case. When we create shortcodes for clients we like to utilize a plugin instead of putting them into the theme. This allows us to continue to use the shortcodes, even if the theme changes. If the styling needs adjusted, it’s much easier to update CSS and not have to rewrite the entire shortcode. WordPress comes built in with a few shortcodes for audio, image galleries and a few other things.

Future-proofing your shortcodes

When we redesign and develop a new WordPress powered website, we will check the current theme for any customized code like Google Analytics or tracking codes, custom meta tags for SEO and also WordPress shortcodes. If we find shortcodes, we’ll move those to a plugin so we can reuse those and not have to mess with rewriting (Yes, sometimes the code is bad and we have to rewrite the plugin a bit, but that’s normal).

Fixing a blank WordPress shortcode problem

If we know what shortcodes are on a post/page, then we can manually remove that shortcode from said post(s) and page(s). But if we have a website with a lot of posts and/or pages with blank or unused shortcodes, then it becomes a bit trickier. A very easy way to just not display that shortcode content is:

add_shortcode( 'shortcode_to_remove', '__return_false' );

This allows us to easily say ‘shortcode_to_remove’ (or whatever your shortcode is) will not get parsed and return blank content instead of showing the shortcode on the page. You can either put this in your functions.php file, but we recommend you create a plugin for this as you’ll probably need the content that was being displayed previously by the shortcode.

Get the Latest

  • Get email updates whenever we post new blog articles.
  • This field is for validation purposes and should be left unchanged.

Recent Articles