get_posts assistance needed
-
I’m trying to use get_posts() to get a list of attachments for a College Class sub-page I’ve built. To organize things, I’m using Categories to identify posts dealing with the College Class, and then I’ve built a Custom Category Template for it.
Here’s the problem:
get_posts() doesn’t appear to be accepting the ‘category_name’ argument. I may be using it wrong, so here’s my code:
<?php $args = array( 'post_type' => 'attachment', 'category_name' => 'rock-history', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, // any parent ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $post) { setup_postdata($post); the_title(); the_attachment_link($post->ID, false); the_excerpt(); } } ?>
Without the ‘category_name’ argument, everything shows from the entire site. With it, nothing shows…including attachments from posts that have the category tag applied.
Do Slugs need to be done with any special formatting? Any suggestions on how to get this to work?
Thanks in advance.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘get_posts assistance needed’ is closed to new replies.