• I was wondering how you would write a piece of code that whatever template a page was using that the piece of code would generate a list of links to all pages also using that particular template. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    ww.wp.xz.cn Admin

    Hmm. Never seen that question before.

    You could make a new query Loop using the meta_key and meta_value parameters.

    $q = new WP_Query(array(
    'meta_key'=>'_wp_page_template',
    'meta_value'=>get_post_meta( $id, '_wp_page_template', true ),
    ));
    while ($q->have_posts()): $q->the_post();
    the_permalink();
    endwhile;

    Something like that, maybe? Dunno, haven’t tried it.

    Probably requires 2.6 or higher.

    Thread Starter kev_120

    (@kev_120)

    Hey I appreciate the help man but it just brings up random pages from different templates. This will give me a good framework to mess around with but if you or anyone else were to stumble on the solution please don’t hesitate to post it 😉

    Thanks!

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

The topic ‘Listing Links to All Pages Using A Particular Template’ is closed to new replies.