Support » Fixing WordPress » Format Text Output From $my_query

  • Thanks to this post I’ve gotten my sidebar ‘Tip of the Week’ column working. The problem I’m having when using this code . . .

    <?php $my_query = new WP_Query(‘cat=4&showposts=1’); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <?php echo $post->post_title; ?>
    <?php echo $post->post_content; ?>
    <?php endwhile; ?>

    is that the text that is output is not being formatted (i.e. line breaks are not showing up – all text is combined). Any ideas on what I could change to make that happen?

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you mean between the title and content etc, you need to put more html tags there… like <h3><?php echo $post->post_title ?></h3><div><?php echo $post->post_content; ?></div>

    I mean in the body of the post itself.

    Because it is a second loop that is pulling ‘post_content’ directly from the DB, it is not formatting the content. Where there is a line break in the DB, it is not printing a line break on my page.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Format Text Output From $my_query’ is closed to new replies.