Am newbie in WordPress refer my below coding, it’s not getting all records where:
post_author ='1' and post_type ='attachment'
It’s just return single row only. In my db have 20 rows where:
post_author ='1' and post_type ='attachment'
This is my php code:
<?php
$args = array('author' => '1' ,'post_type' => 'attachment');
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
// now $query->post is WP_Post Object, use:
echo $query->post->ID;
}
}
?>
Try below code
Use a custom query