WordPress.org

Support

Support » Plugins and Hacks » [Resolved] get category in image.php

[Resolved] get category in image.php

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

    @eddiemoya

    Im not sure what image.php is. Is it simply part if the theme your using? Or is it part of the template hierarchy that Im not familiar with?

    Attachments are a post type like any other. So generally speaking anything that shows a list of images is going to have some sort of loop. All you need to do is have the id for that image, and pass it to a function like wp_get_object_terms().

    In the case of single image templates, that too should have access to the images ID. The same applies.

    It is part of the 2012-Theme, it is the template for viewing an attachment. I already solved this yesterday and came to the same sollution:

    <?php $terms = get_the_terms( $post->ID , ‘category’ );
    foreach( $terms as $term ) {
    $cat = $term->name;
    unset($term);
    }?>

    Thanks for your reply!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] get category in image.php’ is closed to new replies.