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

I have this php code below for displaying the post from the specific categories.

<ul id="sliderx">
<?php query_posts('category_name=slideshow&showposts=10');
while (have_posts()) : the_post();
echo "<li>".the_content()."</li>";

as you can see, it display those post in the category slideshow and the structure of that should be this.

<ul id="sliderx">
<li>the post 1</li>
<li>the post 2</li>
<li>the post 3</li>

but the output that is generated is this.

<ul id="sliderx">

and the generated structure should not look like that and it looks nasty at all, so im having a problem on this on how to display it properly like to display into this structure.

<ul id="sliderx">
<li>the post 1</li>
<li>the post 2</li>
<li>the post 3</li>

So Im wondering if there's someone who could tell me how to fix this.

Im open into any suggestions, recommendations and suggestions. Thank you.

share|improve this question
up vote 1 down vote accepted

That happens because the_content() contains already an echo. PHP tries to create the string before it sends it to the echo command. While the string is evaluated the content will be printed already. Then echo gets what was not yet printed: the li tags.

So the simple fix is:

echo '<li>';
echo '</li>';
share|improve this answer
brilliant. Works like charm, thank you person. :) – Juliver Galleto Oct 7 '12 at 21:39

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.