[wp-hackers] Exclude page by name in wp_list_pages

Computer Guru computerguru at neosmart.net
Fri Jul 21 07:42:46 GMT 2006

> I know it should be possible with some custom coding, if you can query
> a page by name, I just don't know where to start. any direction would
> be appreciated.

I'm not intimately familiar with the WP database design, but this _should_ work (and, no, it hasn't been tested, and I'm not responsible for any damage =P): 

$wpdb->query("SELECT post_id FROM $wpdb->posts WHERE post_status = 'static' AND post_title = 'Mary Had a Little Lamb'");

And this will return an array with exactly 0 or 1 members, depending on whether or not such a match was found.
post_title is obviously the name of the page, and static tells it to look for _pages_ not posts. The array will have one member: post_id, which is the page id, and you can use that to do anything else you are interested in.

Hope this helps, 

Computer Guru
NeoSmart Technologies

More information about the wp-hackers mailing list