Lorenzo Varano Lorenzo Varano - 1 year ago 113
PHP Question

Wordpress: get subtitle

I have here a loop to get the parent pages titles and featured images. I want to add the subtitle, but the subtitle is not displayed. In other templates I use to get the subtitle of the specific page. But here in the loop I need the subtitles of the parent pages.
I use for the subtitle a plugin wp_subtitle: here is a link

here is the code snippet:

$args = array(
'parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish'
$pages = get_pages($args); ?>
<div style="max-width:1240px;">
<?php foreach( $pages as $page ) { ?>
<div class="box">
<a href="<?php echo get_permalink($page->ID); ?>" rel="bookmark" title="<?php echo $page->post_title; ?>">
<span class="title"><?php echo $page->post_title; ?></span>
<span class="thumbnail"><?php echo get_the_post_thumbnail($page->ID, 'small-thumb'); ?></span>
<span class="subtitle"><?php echo $page->the_subtitle; ?></span>
<span class="desc"><?php echo get_post_meta($page->ID, 'desc', true); ?></span>
<?php } ?>

Answer Source

You should use the function provided by the plugin, get_the_subtitle():

<span class="subtitle"><?php echo get_the_subtitle($page); ?></span>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download