WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Echo the subtitle of a PARENT page within WordPress?

[Resolved] Echo the subtitle of a PARENT page within WordPress?

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

    Function:

    <?php
        $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!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Echo the subtitle of a PARENT page within WordPress?’ is closed to new replies.