So I'm using a custom loop to output a custom post type on some pages.
It works just fine, grabs the content etc, but it doesn't wrap the paragraphs in p tags. I'm relatively new to WP, being as though I've just done front end stuff before, so forgive me if I'm making an elementary mistake here.
<div class="home-grid-1">
<?php
query_posts(array(
'post_type' => 'Headerhome',
'showposts' => 1
) );
?>
<?php while (have_posts()) : the_post(); ?>
<?php echo get_the_content(); ?>
<?php endwhile; wp_reset_query();?>
</div> <!-- end home-grid-1 -->
Instead of echo get_the_content()
, which often does not have filters applied to it, use the_content()
which will automatically echo the post content, with filters applied.
while (have_posts()) : the_post();
the_content();
endwhile;
The filter you need is a transformer of double-line-breaks to <p>
and </p>
. It's called wpaup and is explained here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.