Unattached media archive, sort by category (2 posts)

  1. flint_and_tinder
    Posted 3 years ago #

    Hi all,

    I'm trying to set up an archive page that goes and gets all unattached pdfs from the media library and then displays them along with the category each pdf has been assigned via the Media Categories plug-in.

    I have spotted this thread here - http://wordpress.org/support/topic/sort-posts-by-category-2 - and have used that as a basis and tried to combine my existing pdf loop into it. Unfortunately I'm not a php expert and it doesn't work.

    Can anyone see what I'd have to change to the code below to get it to work please?

    global $query_string;
    $my_query_string = $query_string;
    foreach (array('First Category','Odd Pages','Even Posts') as $catname) {
       $catid = get_cat_id($catname);
        $args = array(
                  'post_type' => 'attachment',
                  'post_mime_type' => 'application/pdf',
                  'numberposts' => 6,
                  'post_status' => null,
                  'post_parent' => 0,
    			  'cat' => $catid,
                  'order' => 'desc'
       $myquery = new WP_Query($args);
       if ($myquery->have_posts()) :
          echo "<h2>Posts for Category $catname</h2>";
          while ($myquery->have_posts()) : $myquery->the_post(); ?>
             <p><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
          <?php endwhile;

    Many thanks,


  2. flint_and_tinder
    Posted 3 years ago #

    I assume if nobody has any ideas that I'll have to set up a Custom Post Type and assign the pdfs to a post.

Topic Closed

This topic has been closed to new replies.

About this Topic