-
Excerpt for Children of page, Thumbnail and Custom Field
Hey Folks,
I have been working on find tuning a bit of code (I am not fluent in PHP so it has been tough) and am almost there except for pulling the custom field. I am displaying the excerpt of the children of the current page as well as thumbnails of those children. I have that all done and working but now I want to show a custom field of each of the child pages of the current page and just cannot figure out how to do it.
Here is what I have so far:
<?php
$pageChildren = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'hierarchical' => '0' ) );
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<h2>ID) . '" title="' . $pageChild->post_title . '">'. get_the_post_thumbnail($pageChild->ID).'</h2>';
if ($pageChild->post_excerpt){
echo '<p>'.$pageChild->post_excerpt.'</p>';
}
}
}
?>
But I want to also have it pull a custom field. So something like this:
<?php
$pageChildren = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'hierarchical' => '0' ) );
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<h2>ID) . '" title="' . $pageChild->post_title . '">'. get_the_post_thumbnail($pageChild->ID).'</h2>';
if ($pageChild->post_excerpt){
echo '<p>'.$pageChild->post_excerpt.'</p>';
}
echo get_post_meta($post->ID, 'website-link', true);
}
}
?>
Any suggestions on that 4th to last line of code for pulling in the custom field?
Thanks much in advance!
-
Got it, for anyone trying to do this here it is:
<?php
$pageChildren = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'hierarchical' => '0' ) );
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<h2><a href="' . get_permalink($pageChild->ID) . '" title="' . $pageChild->post_title . '">'. get_the_post_thumbnail($pageChild->ID).'</a></h2>';
if ($pageChild->post_excerpt){
echo '<p>'.$pageChild->post_excerpt.'</p>';
}
echo get_post_meta($pageChild->ID, 'custom-feild-key-here', true);
}
}
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules