• zonetrap

    (@zonetrap)


    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

    (@nakedape)

    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

    (@zonetrap)

    Great job, nakedape, works perfectly! Thanks a bunch.

    nakedape

    (@nakedape)

    You’re welcome! 🙂

    Thread Starter zonetrap

    (@zonetrap)

    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

    (@nakedape)

    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.