• Resolved jboverhof

    (@jboverhof)


    Looking to display a page of pages, that appear like blog posts, with limited content. Am having trouble with limiting the content.

    Here’s where the page is currently at: https://bechtelfoundation.org/about-us/board/

    And the code I’m currently using:

    <?php
    	$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
    
    	foreach( $mypages as $page ) {
    		$content = $page->post_content;
    		if ( ! $content ) // Check for empty page
    			continue;
    
    	$content = apply_filters('the_content', $content);
    
    	?>
        <div class="recent-post">
    	<div class="post-content">
        	<div class="post-thumb"><?php echo get_the_post_thumbnail($page->ID); ?></div>
            <h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
    		<div class="entry"><?php echo $content; ?></div>
        </div>
        </div>
    	<?php
    	}
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Why not just the the_excerpt()?

    Thread Starter jboverhof

    (@jboverhof)

    Thanks esmi. I tried using the_excerpt initially, but I didn’t realize I had to add an excerpt meta box to my pages through my functions file. Appreciate the help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display pages in blog format with limited content’ is closed to new replies.