So, I have a foreach loop within get_pages that shows a list of child pages within a parent ID.
The titles, featured image, and links come through fine, however I can't get excerpts to show up at all. I'm referencing http://codex.wordpress.org/Function_Reference/get_pages
$args = array(
'child_of' => 16,
'title_li' => '',
'depth' => 0,
'sort_order' => 'DESC',
'sort_column' => 'menu_order'
);
$pages = get_pages( $args );
$output = '';
foreach($pages as $value){
$thumb = get_the_post_thumbnail( $value->ID, $attr = '' );
$output .= "<div class='case-studies-parent'><div class='inner'>";
$output .= "<div class='image'><a href='" . $value->post_name . "' >" . $thumb . "</a> </div>";
$output .= "<div class='title'><a href='" . $value->post_name . "' >" . $value->post_title . "</a></div>";
$output .= "<div class='excerpt'>". $value->post_excerpt . "</div>";
$output .= "</div></div>";
}
echo $output;
I can change $value->post_excerpt
to $value->post_content
and that works correctly, showing the entire page content.
I've also tried with various variations including get_the_excerpt()
, the_excerpt()
and post_excerpt
but to no avail.
Is there something I'm missing? On the Codex page, it has post_excerpt
listed as a correct return, so I'm not really sure why it's not showing. (By the way, yes I have added the MORE tag to my pages)
UPDATE: var_dump($value)
object(WP_Post)[276]
public 'ID' => int 155
public 'post_author' => string '1' (length=1)
public 'post_date' => string '2014-08-07 09:40:53' (length=19)
public 'post_date_gmt' => string '2014-08-07 09:40:53' (length=19)
public 'post_content' => string '<h2>Mobile phone tracking</h2>
<p><span>Parents keen to know the location of their children, and businesses seeking to ensure safety of lone workers have since 2004, been able to purchase a mobile phone tracking service, designed and implemented by InverOak, in conjunction with Cybit for The Carphone Warehouse.</span></p>
<p>The Carphone Warehouse, Europe's leading independent retailer of mobile phones and services, asked InverOak to design a system that tracks the location of any mobile phone in the UK, '... (length=2656)
public 'post_title' => string 'The Carphone Warehouse' (length=22)
public 'post_excerpt' => string '' (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'the-carphone-warehouse' (length=22)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2014-08-11 10:01:34' (length=19)
public 'post_modified_gmt' => string '2014-08-11 10:01:34' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'post_parent' => int 16
public 'guid' => string 'http://inveroak.local/?page_id=155' (length=34)
public 'menu_order' => int 0
public 'post_type' => string 'page' (length=4)
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
So, the post_excerpt is empty. But I don't fully understand why, if it's included in the return on the codex?
UPDATE: So I've discovered the excerpt for pages was removed in 3.1 and have found a manual excerpt function added to the theme functions.php file:
add_post_type_support( 'page', 'excerpt' );
While this seems to work okay, is there any difference between this, and using the tag in the editor? Which is cleaner?
var_dump
of$value
inside theforeach
. But if I remember correctly, in this casethe_excerpt
refers to the manual except, which probably is empty. Paste the result of thevar_dump
in the question.wp_trim_words()
.