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 have content locker plugin.

For locking contents, im using this shortcode:

[wp-like-locker] Your locked content here... [/wp-like-locker]

and I need lock every post on my blog. How could I instert this shortcodes into theme and lock:

Thank you very very very much for your answer and time!

share|improve this question

You can hardcode shortcodes into a theme using do_shortcode. http://codex.wordpress.org/Function_Reference/do_shortcode

echo do_shortcode('[wp-like-locker] Your locked content here... [/wp-like-locker]');

You will most likely want to replace the hard-coded "Your locked content here..." with the function that pulls the content from the editor, like the_content http://codex.wordpress.org/Function_Reference/the_content

It might look like

  // the loop
  $content = get_the_content();
  echo do_shortcode('[wp-like-locker]' . $content .  '[/wp-like-locker]');
share|improve this answer
...or just call the function attached to that shortcode directly and pass $content to it; no need for the extra overhead of do_shortcode... – onetrickpony May 8 '12 at 21:13

It would be both faster and cleaner to write a function to do this and put it in functions.php. It'd look like this (untested):

add_action( 'the_content', 'wpse49094_lock_content' );
function wpse49094_lock_content( $content ) {
    if( in_the_loop() ) {
        $content = do_shortcode( 'do_shortcode('[wp-like-locker]' . $content .  '[/wp-like-locker]');
        return $content;
share|improve this answer

you can use do_shortcode() evaluate your short code.

you can place below code into sigle.php in your wordpress theme. And this will apply all of your posts those are using default template.

    get_template_part( 'content', 'single' ); 

echo do_shortcode('[wp-like-locker]');

echo "Your locked content";

echo do_shortcode('[/wp-like-locker]');

share|improve this answer
This code is wrong. Check out the do_shortcode() Codex page to see how to handle open-close shortcodes. – mrwweb May 8 '12 at 20:51

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.