php code problem (1 post)

  1. Ale Urrutia
    Posted 6 years ago #

    Hello, I have this code to show something if it's a Page or a Subpage, this works well

    // Get $post if you're inside a function
    global $post;
    if ( is_page() && $post->post_parent ) {
    // This is a subpage
    echo ('subpage');
    } else {
    // This is not a subpage
    echo 'page';

    The problem I got is that I can't show this:
    <a href="<?php echo $parent_permalink; ?>"><h2 class="titleh2" title="<?php echo $parent_title; ?>"><?php the_title(); ?></h2></a>
    instead of this:
    echo ('subpage');

    Any Idea how to do that?

    PS: of course, this is inside the loop

Topic Closed

This topic has been closed to new replies.

About this Topic