• How do I show both the Parent and Child titles on Child pages?

    Here is what I want to do:

    Let’s say the parent page is About Us, and the child page is Mission. On the Mission page, I want to see the following:

    About Us {in h1}
    Mission {in h2}

    This is what is currently in my pages.php file:

    ‘<title><?php wp_title(‘«’, true, ‘right’); ?> <?php bloginfo(‘name’); ?></title>
    <?php
    wp_head();
    ?>’

    Thanks!!!

Viewing 1 replies (of 1 total)
  • If you’re looking to show the parent, you can use this (this is the parent, linked to the parent page):

    <?php $parent_title = get_the_title($post->post_parent);?>
    <a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $parent_title;?></a>
     <?php echo $children;?>

    I have to warn you though,what you are trying to do is bad for SEO. The current page title should be the <H1>, and the child should be your <H2>.

    Breadcrumbs would be the proper way to display a backwards architecture. Think about your links as you would a Table of Contents on an essay…

    If you want complete breadcrumbs, you can paste this in your functions.php file before the close php at the end:

    function the_breadcrumb() {
    	if (!is_home()) {
    		echo '<a href="';
    		echo get_option('home');
    		echo '">';
    		bloginfo('name');
    		echo "</a> ?? ";
    		if (is_category() || is_single()) {
    			the_category('title_li=');
    			if (is_single()) {
    				echo " ?? ";
    				the_title();
    			}
    		} elseif (is_page()) {
    			echo the_title();
    		}
    	}
    }

    Then add this in your page/post template:

    <?php the_breadcrumb(); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Want to show Parent as title and child as subtitle on child pages’ is closed to new replies.