I want the wordpress exclude pages plugin to work with my theme. Here is where my theme queries for all the pages and displays them all in a row on a single page.
$pagepull = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' ORDER BY menu_order", ARRAY_A);
foreach ($pagepull as $single_page){
echo $single_page['post_content'];
// do other stuff too
}
Do you have any ideas on how to adjust the query to work with exclude pages? There isn't a function to get all pages is there? I know there is wp_list_pages() to get the list of pages but i'm not trying to display a nav here.
Would it be a better idea to do 2 queries, 1 where you get the list of pages, and then 2 query for that list? Not entirely sure how to do that, but an extra query sounds like a bad idea. Thoughts?
UPDATE: from the answer below I have found this to work:
$excluded = ep_get_excluded_ids();
foreach ($excluded as $removepage){
echo "";
$limits .= " AND id != $removepage";
}
$pagepull = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' $limits ORDER BY menu_order", ARRAY_A);
Now, for safety sake, how do I test to see if a plugin's function exists? Sense I rely on ep_get_excluded_ids(); from the Exclude Plugin to be installed.
UPDATE2: - removed - (i had a simple misspelling in this problem, never mind this)
If you are trying to return all but specified pages (and you don't want the formatting of wp_list_pages()
), you could do:
$excArr = array(5,7,10);
foreach($excArr as $p)
$limits .= " AND id != $p";
$pagepull = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' $limits ORDER BY menu_order", ARRAY_A);
Another option would be to use wp_list_pages()
and style the <li>
and <ul>
elements so they don't look like a list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.