Title: Linkable headers
Last modified: August 18, 2016

---

# Linkable headers

 *  [zonetrap](https://wordpress.org/support/users/zonetrap/)
 * (@zonetrap)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/linkable-headers/)
 * I am using the following code in my sidebar:
    `<?php global $wp_query; if( empty(
   $wp_query->post->post_parent) ) { $parent = $wp_query->post->ID; $parent_title
   = $wp_query->post->post_title; } else { $parent = $wp_query->post->post_parent;
   $parent_title = $wpdb->get_var(“SELECT post_title FROM $wpdb->posts WHERE ID 
   = $parent”); } ?> <h2><?php echo apply_filters(‘the_title’, $parent_title); ?
   ></h2>
    - <?php wp_list_pages(“title_li=&child_of=$parent”); ?>
 * ‘
 * Is there a way to make <h2></h2> linkable? The parent titles as these sidebar
   headers are great, but making them linkable would be even better. Any help?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [nakedape](https://wordpress.org/support/users/nakedape/)
 * (@nakedape)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/linkable-headers/#post-541700)
 * Does this work?
 * `<h2><a href="<?php echo get_permalink($post->ID); ?>" ><?php echo apply_filters('
   the_title', $parent_title); ?></a></h2>`
 * – John
 *  Thread Starter [zonetrap](https://wordpress.org/support/users/zonetrap/)
 * (@zonetrap)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/linkable-headers/#post-541702)
 * Great job, nakedape, works perfectly! Thanks a bunch.
 *  [nakedape](https://wordpress.org/support/users/nakedape/)
 * (@nakedape)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/linkable-headers/#post-541704)
 * You’re welcome! 🙂
 *  Thread Starter [zonetrap](https://wordpress.org/support/users/zonetrap/)
 * (@zonetrap)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/linkable-headers/#post-541711)
 * One minute, for example, I have a sidebar that with a category of Fruit with 
   apples and oranges as subpages. If I click Fruit it goes to the Fruit page, but
   if I click a subpage like apples, t goes to apples, but if I try clicking Fruit,
   it keeps me at apples.
 * Any idea?
 *  [nakedape](https://wordpress.org/support/users/nakedape/)
 * (@nakedape)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/linkable-headers/#post-541713)
 * Can you link me or email me (amenbreaka[at]yahoo.com) your blog address so I 
   can take a look? May need to use `cat` template tags instead of the permalink…
 * Are your Fruit, apples, oranges static _pages_ or _categories_?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Linkable headers’ is closed to new replies.

 * In: [Installing WordPress](https://wordpress.org/support/forum/installation/)
 * 5 replies
 * 2 participants
 * Last reply from: [nakedape](https://wordpress.org/support/users/nakedape/)
 * Last activity: [19 years, 2 months ago](https://wordpress.org/support/topic/linkable-headers/#post-541713)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
