Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter lmann

    (@lmann)

    Took a different approach. Thanks anyways.

    Thread Starter lmann

    (@lmann)

    For anyone who is interested in having only specific pages show on a unique sidebar in a unique page template, you can use the code above. If you want to have multiple template exclusions the code is below:

    <?php
    $template = ‘clients.php’; //name of custom page template
    $template2 = ‘photo.php’; //name of 2nd custom page temp

    $Pages = $wpdb->get_col(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘_wp_page_template’ AND meta_value = ‘$template'”);
    foreach($Pages as $Page) {
    $exclude_Pages .= $Page . ‘,’;
    }
    $Pages = $wpdb->get_col(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘_wp_page_template’ AND meta_value = ‘$template2′”);
    foreach($Pages as $Page) {
    $exclude_Pages .= $Page . ‘,’;
    }
    wp_list_pages(“exclude=$exclude_Pages&title_li=”);
    ?>

    Thread Starter lmann

    (@lmann)

    How would it work if I wanted to exclude multiple templates, for example: clients.php and articles.php?

    <?php
    $template = ‘clients.php’;

    $Pages = $wpdb->get_col(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘_wp_page_template’ AND meta_value = ‘$template'”);
    foreach($Pages as $Page) {
    $exclude_Pages .= $Page . ‘,’;
    }
    wp_list_pages(“exclude=$exclude_Pages&title_li=”);
    ?>

    Thread Starter lmann

    (@lmann)

    Thats great – thanks!

    Thread Starter lmann

    (@lmann)

    Thanks –

    but will your example automatically update the sidebar unique to the specific template page. Basically, will I need to go into the php code for a specific sidebar to exclude certain pages everytime I create a new page.

    A work around for this is creating multiple authors and then assigning authors to a page, this way only pages who are written by a certain author will appear in a particular sidebar. I would like to apply the same thing to page templates. Basically, whenever I create a page, I assign it to a specific page template. The unique sidebar associated with that specific template will then be automatically updated. Thanks for your help

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