In my post I have a shortcode for [video] than text content. Single post page displays first entry-meta, than title, than content [video] + text. What I need is to add some condition in single.php so that the order for display to be [video] ->entry-meta ->title ->text. Or maybe there is a function to check if I have [video] shortcode in post to display it first than the title and after rest of the content. Can anyone please help?

I know that tut but I don't know how to use it in single.php.

if(has_shortcode('your_short_code')) {  
    // perform actions here  ... 
    // I want to have: do shortcode [video id] or something like this

I need an example in single.php

I just want to have in single.php displayed first the [video id] after meta than Title +Content


the_content([with video]);

the_content(without video);
  • Use the code from this answer, and just set the video to the start of the content.
    – fuxia
    Commented Oct 12, 2012 at 9:34

1 Answer 1


There's a fast and easy tutorial for writing your own has_shortcode() function over at WP tuts.

  • Lone link is considered a poor answer since it is meaningless by itself and target resource is not guaranteed to be alive in the future. Please try to include at least summary of information you are linking to.
    – Rarst
    Commented Oct 12, 2012 at 11:48

Your Answer

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

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