WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to display different shortcodes inside custom fields.

I have found a method that almost works perfect, but since that uses get_content, it also shows the main featured image of the page.
After the image that's output, the correct content that the shortcode outputs is displayed correctly. How can I stop the image from being output in the first place?

I'm using css to hide it, but would rather not have it output at all. I've tried using this other method which used get_the_content instead, and that doesn't work.
The shortcode content doesn't even show at all with that method.

I also found this:

echo preg_replace("/\< *[img][^\>]*[.]*\>/i","",get_the_content(),1); 

Does anyone know how to make that filter work for me with the code I'm using (shown in the pastebin link).

share|improve this question

No need to deal with the content, use the do_shortcode function directly on your metadata:

echo do_shortcode( $your_meta_data );
share|improve this answer
Hey, thanks for your reply, but that is how I normally use my short codes in my custom template pages, but this time I will need to be able to use different short codes on numerous pages, and will need to be able to do this in the pages backend. Not by editing my templates everytime. – Anthony Myers Dec 31 '12 at 2:20
How does it differ from the method you posted? You're just running your meta data through this function rather than applying content filters. You don't have to hardcode the shortcode into the template. – Milo Dec 31 '12 at 2:29
In other words, when I use the method that you posted, the only thing that is output is the actual words, [my custom shortcode text shows] in my page, and not the content that the short code should be outputting. – Anthony Myers Dec 31 '12 at 2:43
That shouldn't be the case, does this happen with all shortcodes? – Milo Dec 31 '12 at 2:56
No, short codes work fine on their own, but when trying to insert a short code inside a custom field, I have to use the method I posted on Pastebin. It works, but I just need it to not output the featured image along with it. – Anthony Myers Dec 31 '12 at 3:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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