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

    <?php
    // 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

  • The topic ‘php code problem’ is closed to new replies.