Support » Plugin: Taxonomy Images II » [Plugin: Category Images II] No results when specifying category ids

  • Hey, I’ve got the template tag working within the loop without args, but I need it to just load a single image, so I’ve passed in the first category ID for the post, just to test. e.g:

    ciii_category_images( 'category_ids=325' );

    The ID is definitely correct, because it loads the thumbnail for this category fine through the category edit screen and for posts in that category when not specifying ids.

    Help?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Fixed it…

    On line 527 where it handles cat IDs:

    // Cat ID(s) passed?
    if ( $r[ 'category_ids' ] !== false ) {
    $cat_ids = explode( ',', $r['category_ids'] );
    $CategoryImagesII->display_images( $cat_ids, $r[ 'link_images' ] );
    return;
    }

    It stores the images in $CategoryImagesII but then returns nothing, nor does it echo because it never gets to the part where it decides to echo (depending on echo arg) on line 541 because its already returned.

    The simplest fix is to return the result in that same line, e.g.

    return $CategoryImagesII->display_images( $cat_ids, $r[ 'link_images' ] );

    But I really needed it to work with the echo arg, so I altered that whole section, to either get the ids from the passed ids or the loop, then do the echo part as normal.

    // Cat ID(s) passed?
    if ( $r[ 'category_ids' ] !== false ) {
    	$cat_ids = explode( ',', $r['category_ids'] );
    // In the loop?
    } else {
    	$categories = get_the_category();
    	$cat_ids = array();
    	foreach ( $categories AS & $category ) {
    		$cat_ids[] = $category->cat_ID;
    	}
    }
    
    if ( ! $r[ 'echo' ] )
    	return $CategoryImagesII->display_images( $cat_ids, $r[ 'link_images' ] );
    echo $CategoryImagesII->display_images( $cat_ids, $r[ 'link_images' ] );

    more troubles with the echo var, the following, where it looks for a different echo setting to default (which is true):

    if ( ! $r[ 'echo' ] )

    …was always reading true (so skipping the return and just echoing), even though i was passing it echo=false along with the cat IDs:

    ciii_category_images('category_ids=10&echo=false');

    I changed the type comparison in the if statement and it works now with this instead:

    if ( $r[ 'echo' ] !== true )

    sorry, not sure if all this is necessary but its been giving me problems at least.

    Hit the same problem and resorted to using a direct call to the class method:

    global $CategoryImagesII;
    echo $CategoryImagesII->display_images( array($cat_id), true );

    Thanks a lot Teeks! Your solution fixed my issue too.

    cool having the same issue. Tried to contact the author via their site last week and haven’t heard anything back. Thanks.

    Yeah I had the same problem was gonna post the solution here but you beat me to it – though all I did was add echo to line 530 of category-images-ii.php

    was

    // Cat ID(s) passed?
    	if ( $r[ 'category_ids' ] !== false ) {
    		$cat_ids = explode( ',', $r['category_ids'] );
    		$CategoryImagesII->display_images( $cat_ids, $r[ 'link_images' ] );
    		return;
    	}

    I changed it to

    // Cat ID(s) passed?
    	if ( $r[ 'category_ids' ] !== false ) {
    		$cat_ids = explode( ',', $r['category_ids'] );
    		echo $CategoryImagesII->display_images( $cat_ids, $r[ 'link_images' ] );
    		return;
    	}

    Job done!

    hey guys, any chance i could abuse your skills on this to ask how i could also echo the name of the category as well as the picture ? Thanks in advance.

    Found the solution, was pretty simple. I just needed to add this:
    <a href="<?php echo esc_attr( get_category_link( $category[ 'id' ] ) ); ?>"><?php echo $category[ 'name' ]; ?></a>

    in plugins\category-images-ii\view\category-images-ii\category-images.php

    Hi. I want to show the category image for each category in a list of categories with title and description but I cant’t figure out how to do it. Can anyone help me with my code?

    My code look like this:

    <?php
    	$args=array(
    	'parent' => 230,
    	'orderby' => 'slug',
      	'order' => 'DESC',
    	'hide_empty' => 0
      	);
    	$categories=get_categories($args);
      	foreach($categories as $category) {
        echo '<div class="category-productos">';
    	echo '<div class="thumbnail-category">';
    // I WANT THE PICTURE HERE
    	echo '</div>';
    	echo '<div class="post-text">';
    	echo '<h3 id="'. $category->cat_ID .'"><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '">'. $category->cat_name .'</a></h3><div class="wraper"></div>';
        echo '<p>'. $category->description . '</p>';
    	echo '</div>';
    	echo '<div class="wraper"></div></div>';
    	}
    ?>

    Everything works ok except for the picture. Any help would be apreciated.

    Thanks in advance.

    ps: sorry for my english.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Category Images II] No results when specifying category ids’ is closed to new replies.