How to get url of all pages of the attachments?

Try this code — nothing displays

test_attachment_url function(){
 $aaa =";
 $parametri = array(
 'post_type' => 'attachment', /* Select only records. */
 'posts_per_page' => -1, /* Remove the limit on the number of displayed records per page. */
);
 $moi_zapros = null;
 $moi_zapros = new WP_Query($parametri); /* form a new "non-standard" request. */
 if ($moi_zapros->have_posts()):
 while ($moi_zapros->have_posts()) : $moi_zapros->the_post(); 
$idt=get_the_ID();
 $aaa = $aaa .'<a href="'.get_permalink($idt).'">'.get_permalink($idt).'</a><br>';
endwhile;
endif;
 wp_reset_query(); /* Reset our sample. */
March 19th 20 at 08:50
1 answer
March 19th 20 at 08:52
Because you did not withdraw. And the function returns nothing
Try this:
while ($moi_zapros->have_posts()) : $moi_zapros->the_post(); 
$idt=get_the_ID();
 echo '<a href="'.get_permalink($idt).'">'.get_permalink($idt).'</a><br>';
 endwhile;
well, I just never put the end of the code. The code works if
'post_type' => 'post' - cesar51 commented on March 19th 20 at 08:55

Find more questions by tags WordPress