yep, use conditional tags.
http://codex.wordpress.org/Conditional_Tags
example:
<?php if (is_page('4')) {
wp_list_pages('exclude=1,2,3'); } ?>
Edit: Actually if you’re using unique sidebars to those pages, skip the is_page conditional tags and just use the exclude= in wp_list_pages.
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
Don’t know if you have the skill to build on it (or around your own needs), but I’ve previously coded a solution for excluding Pages based on the Page template in use:
http://wordpress.org/support/topic/57061#post-309307
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)
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=”);
?>