Support » Plugin: Media Categories » use in category.php

  • Resolved deepbevel


    I have this in category.php

    $args = array(
    'post_type' => 'attachment',
    'numberposts' => -1,
    'post_status' => null,
    'post_parent' => $post->ID,
     'cat' => 14
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ( $attachments as $attachment ) {
    		echo apply_filters(

    I’m currently doing with a conditional for media category id=15:

    if(is_category('my-media-category')) {

    but, rather than include cat => 15,
    is there a way to get the attachments from whatever post category is current in category.php?

    my categeory.php template
    what if looks like on the site
    ..pending any fiddling I may do in the mean time.


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Eddie Moya


    How you get the current category depends on several aspects of where your trying to do it. You can use get_the_category() or get_query_var(‘cat’). Theres other ways, depends on your circumstances. In any case getting the current category is a question about WordPress, not this plugin. I would suggest the forums, stackoverflow, or other areas where you can ask your question to a larger audience.

    thanks, and sorry, it’s hard to draw the line sometimes.. Media Cateories appear in the standard wp categoriy widget, but when the links are clicked, no images appear in category.php.

    I understand it’s because no attachments are being called in the output, but when I try to do that, I get all attachments unless I specify a category.

    So, if the plugin can’t get categories like it does posts (without adding conditionals), I don’t want to spend too much time trying, with the mistaken assumption that I only need to understand the wp part to make it happen. Hope that makes sence.

    Anyway I’ll resolve the thread, if there’s anythng else you could share regarding this it’s most appreciated.

    media-categories with the attachment images, image titles, parent post titles, and linked author display names. It’s exact;y what I’ve been after. Finally!
    code as used in category.php for twentyten

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘use in category.php’ is closed to new replies.