In the members-only forum, a user asked:
Hi Sridhar,
I cannot find anything that works… how can I leave out a few pages, like “thank you” pages in the page_sitemap.php in Genesis.
In my case, I am using your genesis-sample-master and I want to leave out Page ID:11 and ID:720.
The Genesis Archive Template uses wp_list_pages()
function to display a list of all static Pages on a Page to which the template has been applied.
WordPress provides a wp_list_pages_excludes
filter which can be used to set specific Pages from not appearing in the list output by wp_list_pages().
Adding the following in child theme’s functions.php will exclude Pages having the IDs of 11 and 720 from appearing in anywhere a list of Pages are output using the wp_list_pages():
add_filter( 'wp_list_pages_excludes', 'filter_wp_list_pages_excludes', 10, 1 );
/**
* Exclude specific Pages from wp_list_pages().
*
* @param array $exclude_array Current array of Page IDs to be excluded from wp_list_pages().
*/
function filter_wp_list_pages_excludes( $exclude_array ) {
return array_merge( $exclude_array, array( 11, 720 ) );
}
If you would like to limit the Pages exclusion to only on Genesis Archive Template Page, use this instead:
add_filter( 'wp_list_pages_excludes', 'filter_wp_list_pages_excludes', 10, 1 );
/**
* Exclude specific Pages from wp_list_pages().
*
* @param array $exclude_array Current array of Page IDs to be excluded from wp_list_pages().
*/
function filter_wp_list_pages_excludes( $exclude_array ) {
if ( is_page_template( 'page_archive.php' ) ) {
$exclude_array = array_merge( $exclude_array, array( 11, 720 ) );
}
return $exclude_array;
}
References:
genesis/page_archive.php
genesis/lib/functions/general.php