• Resolved kongkang

    (@kongkang)


    How to display title of Parent Page & Sub Page in same time?

    Example Snippet

    <?php
    
    global $post;     // if outside the loop
    
    if ( is_page() && $post->post_parent ) {
        // Show Parent Title & Sub Title here
    
    } else {
        // Show Parent Title
    }
    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter kongkang

    (@kongkang)

    Thanks

    global $post; // if outside the loop
    
    if (is_page() && $post->post_parent) {
        $parent_title = get_the_title($post->post_parent);
    
        echo ' &raquo; <a href="' . get_permalink($post->post_parent) . '">' . $parent_title . '</a> &raquo; ';
        wp_title('');
    
    } else if (is_page()) {
        echo ' &raquo; ';
        wp_title('');
    
    } else {
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Display title of parent & sub page’ is closed to new replies.