Get pages list with custom fields
-
After doing some research I was advised that I should use get_posts to retrieve a list of pages that meet a set criteria. I have the following query:
Though instead of pulling out the pages that have the Partner_Level = Gold key value pair, I get all the pages in my site retrieved.
Where am I going wrong?
function the_partners() { $args = array( 'meta_query' => array( array( 'meta_key' => 'Partner_Level', 'meta_value' => 'Gold' ), 'post_type' => 'page', 'post_status' => 'publish' )); $pages = get_pages( $args ); $pages = get_pages( $args ); foreach ( $pages as $page ) { $option = '<option value="' . get_page_link( $page->ID ) . '">'; $option .= $page->post_title; $option .= '</option>'; echo $option; } }[Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently dmaged/corrupted by the forum’s parser.]
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
The topic ‘Get pages list with custom fields’ is closed to new replies.