Format Text Output From $my_query (3 posts)

  1. stuboo
    Posted 11 years ago #

    Thanks to this post http://wordpress.org/support/topic/34158 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?

  2. Firas
    Posted 11 years ago #

    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>

  3. stuboo
    Posted 11 years ago #

    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.


Topic Closed

This topic has been closed to new replies.

About this Topic