WP_Query Filtred by author name ( Return null )

Question

I want to list all pages whose author has a specific name but WordPress returns null values

<?php
$args = array(
'author_name '=> 'admin',
'post_type'=>'page');
$pages = new WP_Query($args);
foreach ($pages as $page) {
var_dump($page->post_title);
}
?>

result is

NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL string(4) "test" NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
0
danial rafiee 3 months 0 Answers 5 views 0

Leave an answer