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.

I am trying to put several queries in a shortcode so that I can call them in a page instead of using custom templates. I got my query going but I only see some of the content on the page. The image shows up, the text shows up but none of the html markup is showing up. is there a wordpress function that I need to pass this all through so it doesn't strip the html?

 function band_query($atts) { ?>
<ul>
  <?php                         
 extract(shortcode_atts(array(
 "category" => '',
 "number" => ''
 ), $atts));

  $band = new WP_Query( array(
    'category_name' => $category,
'posts_per_page' => $number
 ));
$output = '';
 // The Loop
 if( $band->have_posts()):
$output .= '<div id="band_bio">';
$output .= '<ul>';
    while ( $band->have_posts() ) : $band->the_post(); 
$output .= '<li>';
$output .= '<figure>' . the_post_thumbnail('band', array('class' => 'left marg_right1')) .' </figure>';
 if ( has_excerpt()){
    $output .= the_excerpt();
} else {
    $output .= the_content(); 
}                                   
$output .= '<div class="relative"><a href=' .the_permalink() . 'class="button1">  <span></span><strong>Read More</strong></a></div>';
$output .= '</li>';
endwhile; endif;
  wp_reset_postdata();
$output .= '</ul>';

$output .= '
</div>
   <a href="#" class="prev"></a>

   <a href="#" class="next"></a>

$output = apply_filters('the_content', $content);
return $output;


 }
 add_shortcode("band_page", "band_query");
share|improve this question
1  
You forgot a closing quote. Look at the output of the syntax highlighter. –  toscho Apr 20 '13 at 22:52
    
And the first <ul> is outside of $output. Also, using a nice indentation in the code makes it easier to read and debug. –  brasofilo Apr 21 '13 at 0:12
    
my syntax highlighter doesn't show a missing anything. I don't see one either. As far as the indenting. Is there a trick to getting it to work on this site? I do indent my code and then I have to spend 10 minutes trying to make it look readable here. Eventually, I get it close enough and post it. It loses all formatting when I copy it over –  Jamie Apr 21 '13 at 3:15

1 Answer 1

up vote 4 down vote accepted

When you are constructing the $output variable, you need to consider

get_the_post_thumbnail()
get_the_excerpt()
get_the_content()
get_permalink()

that return the values instead of

the_post_thumbnail()
the_excerpt()
the_content()
the_permalink()

that echo the values.

share|improve this answer
    
Thank you for your reply. This helped a lot –  Jamie Apr 21 '13 at 22:55

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.