I have this page where I am showing all post’s attachments.
This is the code:
<?php
$args = array(
'post_type' => 'attachment',
'post_status' => 'published',
'posts_per_page' =>25,
'post_parent' => null, // Post-> ID;
'numberposts' => null,
);
$attachments = get_posts($args);
$post_count = count ($attachments);
if ($attachments) {
foreach ($attachments as $attachment) {
echo "<div class="post photo col3">";
$url = get_attachment_link($attachment->ID);// extraigo la _posturl del attachmnet
$img = wp_get_attachment_url($attachment->ID);
$title = get_the_title($attachment->post_parent);//extraigo titulo
echo '<a href="'.$url.'"><img title="'.$title.'" src="'.$img.'"></a>';
echo "</div>";
}
}
?>
Now, I have the ‘post’, ‘page’ and ‘videos’ post_types.
I am getting all of them but I want to display ‘post’ post_type only.
How do I exclude ‘video’ post_type?
Thanks!
just paste the following code anywhere in your post file and attachments will be displayed.