• skunkbad

    (@skunkbad)


    I’m trying to add two pages worth of content on one page like this:

    $args = array(
    	'post_type' => 'page',
    	'post__in'  => array(
    						'9', // About Us Part 1
    						'13' // About Us Part 2 - Right Side
    	),
    	'order' => 'asc'
    );
    
    $the_query = new WP_Query( $args );
    while($the_query->have_posts()) : $the_query->the_post();
    $part[] = get_the_content();
    endwhile;
    
    echo $part[0];
    
    echo $part[1];

    This works for bringing in two pages of content, but the automatic addition of p tags doesn’t happen, and I’m wondering why. It seems like everyone wants to get rid of the p tags, but I need them! Using HTML view is not an option. If anyone can help, I’d appreciate it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • donuthole

    (@donuthole)

    You are displaying the raw, unformatted data from the database. To add the paragraph and other tags, you can call:

    echo apply_filters('the_content',$part[0]);

    echo apply_filters('the_content',$part[1]);

    Thread Starter skunkbad

    (@skunkbad)

    Thank you for your answer. I have a question about it. How would using your code differ from:

    echo wpautop($part[0]);
    
    echo wpautop($part[1]);
    Alwyn Botha

    (@123milliseconds)

    Thread Starter skunkbad

    (@skunkbad)

    Hey, that’s cool. So the answer is, the_content runs the raw data through the following functions:

    * wptexturize
    * convert_smilies
    * convert_chars
    * wpautop
    * shortcode_unautop
    * prepend_attachment
    * do_shortcode

    and wpautop is only one of them. I kinda figured it was something like that. Thanks for your time!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Combining Pages strips out p tags, which I want to be automaticly added’ is closed to new replies.