Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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]');

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

1 Answer 1

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

 
discard

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.