WordPress.org

Ready to get started?Download WordPress

Forums

Media Categories
[resolved] use in category.php (4 posts)

  1. deepbevel
    Member
    Posted 1 year ago #

    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.

    thanks!

    http://wordpress.org/extend/plugins/media-categories-2/

  2. Eddie Moya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

    http://codex.wordpress.org/Function_Reference/get_the_category

  3. deepbevel
    Member
    Posted 1 year ago #

    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.

  4. deepbevel
    Member
    Posted 1 year ago #

    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!
    example
    code as used in category.php for twentyten

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.