[resolved] Echo the subtitle of a PARENT page within WordPress? (2 posts)

  1. jodriscoll
    Posted 3 years ago #

    I'm attempting to fetch the subtitle from the PARENT page and echo the text within a title tag.


        $id_to_get = $post->ID;
        if ( $post->post_parent ) {
            $id_to_get = $post->post_parent;
        $parent = $id_to_get;
        $title = get_the_title($parent);
        $subtitle = get_post_meta($id_to_get, '_base_page_subtitle', true);

    HTML Implementation:
    ...title="<?php echo $subtitle; ?>">

    Unfortunately, it is not successfully grabbing the subtitle text. I'm able to populate the title echoing the variable $title, just not with the variable $subtitle.

    The value for the Subtitle option is stored within the table "_base_page_subtitle"; I'm using options framework.

    I know my issue is with the if statement, however, being new to PHP, I'm having a bit of difficulty figuring out how to capture the data and display it properly.

    Thanks again of time!

  2. jodriscoll
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic