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

  • Can you use a heredoc? – JMB Jan 6 '14 at 0:34
  • 2
    I don't think I understand the question. – s_ha_dum Jan 6 '14 at 1:33
  • 1
    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().

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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