Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

madphill on "Query posts with attachments by category"

$
0
0

I'm attempting to pull media from posts by category and the media is showing up, it's just not by category. It's currently ALL media regardless of whether or not it's attached to a post. I'm having trouble figuring out what to do.

<div class="row-fluid">
<?php
global $post;
$args = array(
'post_category' => 'trees',
'post_type' => 'attachment',
'numberposts' => 8,
'orderby' => 'random',
'post_status' => null,
'post_parent' => null, // any parent
);
$attachments = get_posts($args);
foreach ($attachments as $post) : setup_postdata($post); ?>
<div class="span3">

Viewing all articles
Browse latest Browse all 8245

Trending Articles