Title: php code problem
Last modified: August 19, 2016

---

# php code problem

 *  [Ale Urrutia](https://wordpress.org/support/users/alectro/)
 * (@alectro)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/php-code-problem/)
 * 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.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 0 replies
 * 1 participant
 * Last reply from: [Ale Urrutia](https://wordpress.org/support/users/alectro/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/php-code-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
