How to Insert Shortcodes into Theme?

I have content locker plugin.

For locking contents, im using this shortcode:

Read More

[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!

Related posts

Leave a Reply

3 comments

  1. 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]');
    
  2. 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;
        }
    }
    
  3. 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.

       <?php 
        get_template_part( 'content', 'single' ); 
    
    echo do_shortcode('[wp-like-locker]');
    
    echo "Your locked content";
    
    echo do_shortcode('[/wp-like-locker]');
    
    ?>