• Greetings!

    I’m in the process of building an install for a client, when I noticed that one of my custom functions wasn’t working. The function is designed to return an array that is specially designed for the rendering of a ‘select’ option field.

    The function points to a few other custom functions before the actual output is rendered. However, when I started noticing problems, I “cut out the middle man,” so to speak, and replaced the function code with this:

    $pages = get_pages( array( 'sort_column' => 'menu_order', 'meta_key' => '_wp_page_template', 'meta_value' => 'page-bio.php' ) );
    print_r( $pages );

    The array should contain pages of a particular page template (page-bio.php). I can look in the database, in the ‘postmeta’ table, and see that there is at least one page using the page template ‘page-bio.php’. Yet the output of the above code is as follows:

    Array ( )

    I’ve looked through the get_pages() code in /wp-includes/post.php, I’ve checked, double-checked, and triple-checked everything to make sure it’s all solid. I can’t for the life of me figure out why get_pages() isn’t returning the pages like it should.

    Any ideas?

    (Many thanks in advance.)

Viewing 1 replies (of 1 total)
  • Thread Starter S. Wyatt Young

    (@swyattyoung)

    It’s worth noting that get_posts() works just fine. I just replaced get_pages() in the relevant functions, changing the arguments as necessary, and things work just fine now. This appears to be an issue with get_pages().

Viewing 1 replies (of 1 total)
  • The topic ‘get_pages() Not Returning Posts with 'meta_key' and 'meta_value'’ is closed to new replies.