WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

So I want to put a loop of post behind a 'like lock' thats created by a plugin that uses the shortcode [to_like ID="XX"]content[/to_like]. But instead of the plugin blocking the content, i just get a page with all the permalinks to the post on it.

So I guess what Im asking is how do I put the page contents (ie, the loop in the template that displays the post) inside the shortcode so its hidden by the plugin?

This is what Ive got right now:

foreach ( $posts as $post ) :
  setup_postdata( $post ); 
    $content  = '<li><div itemscope itemtype="http://schema.org/LocalBusiness">';
    $content .= '<span itemprop="name"><a href="'.the_permalink().'" tilte="'.the_title().'">'.the_title().'</a></span>';
    $content .= '<span itemprop="description"></span>';
    $content .= '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';

            $schemaStreet = get_post_meta( $post->ID, 'schemaStreet', $single );
            $schemaCity = get_post_meta( $post->ID, 'schemaCity', $single ); 
            $schemaState = get_post_meta( $post->ID, 'schemaState', $single );

    $content .= '<span itemprop="streetAddress">'.$schemaStreet[0].'</span>';
    $content .= '<br /><span itemprop="addressLocality">'.$schemaCity[0].'</span>, <span itemprop="addressRegion">'.$schemaState[0].'</span>';

    $content .= '</div>';
    $content .= '</div>';
    $content .= '</li>';

    do_shortcode('[to_like id="1208"]'.$content.'[/to_like]');

share|improve this question
Can you use a heredoc? – JMB Jan 6 '14 at 0:34
I don't think I understand the question. – s_ha_dum Jan 6 '14 at 1:33
Please follow up on your old questions answers and comments. – kaiser Feb 10 '14 at 23:25

Your issue with output is because you are using versions of template tags that immediately output the result when called, rather than return it to be concatenated with the string.

For example the_permalink() as opposed to get_permalink().

share|improve this answer

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.