• Resolved yolise

    (@yolise)


    I’ve searched for plugins to accomplish this, but none of them do quite what I’d like (as they have to run inside the loop or on a single archive page).

    Essentially, I want to display a page of images with links to the archive page for each category, instead of the category names. I could conceivably do this by creating category images with titled slug.jpg, but I can’t work out how to extract a list of category slugs and links.

    Would I be doing something with “echo” perhaps? Not entirely sure what that does, sadly. 🙁

Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Thread Starter yolise

    (@yolise)

    No, but will have a look. Thanks.

    One of these days I will figure out what “taxonomy” means.

    Thread Starter yolise

    (@yolise)

    Hmm, well, that’s very nice, but again, it only seems to be able to display category images on the archives page or on a post. At least as far as I can work out from the screencast.

    I really want a page that lists all my categories using a image link for each one, rather than a bulletted text link.

    Basically, I want to somehow get inside wp_list_categories and pull out the url and name (or ID) of each category.

    Moderator keesiemeijer

    (@keesiemeijer)

    By default, WordPress comes with 3 taxonomies: post tag taxonomy, category taxonomy, link categories taxonomy.
    Each tag or category you create is a “term” within that taxonomy. For example, if you create a category “Movies”, “Movies” becomes a term within the category taxonomy. And since WordPress 2.8 you can make your own custom taxonomies.
    Very confusing indeed!

    Moderator keesiemeijer

    (@keesiemeijer)

    Did you see this on the plugin page:

    This code can be placed inside any theme template and will produce a string of links for every taxonomy that has an associated image.

    $cats = get_categories();
    foreach ( $cats as $c ) {
        $url = get_category_link( $c->term_id );
        $img = $taxonomy_images_plugin->get_image_html( 'detail', $c->term_taxonomy_id );
        if( !empty( $img ) )
            print '<a href="' . $url . '">' . $img . '</a>';
    }
    Thread Starter yolise

    (@yolise)

    Ah, no, I didn’t. I just watched the screencast. And I think that “taxonomy” word threw me again as well.

    Thank you!

    edit:
    a bit late; i was doing other stuff while this was on my screen – don’t get mixed up, and keep following the replies before.

    <?php
    $category_ids = get_all_category_ids();
    foreach($category_ids as $cat_id) {
      $cat = get_category($cat_id);
      $link = get_category_link( $cat_id ); ?>
      <div class="cat-image">
      <a href="<?php echo $link; ?>" title="link to <?php echo $cat->name; ?>">
      <img src="<?php bloginfo('template_url'); ?>/images/<?php echo $cat->slug; ?>.jpg" />
      </a>
      </div>
      <?php
    }
    ?>

    using your idea with the ‘cat_slug.jpg’ image;
    this assumes that the images are in the /images folder of your theme.
    the div is optional to help with formatting.

    based on:
    http://codex.wordpress.org/Function_Reference/get_all_category_ids

    PS:
    taxonomy
    not to be confused with
    taxidermy

    Thread Starter yolise

    (@yolise)

    Well, the plugin is working well for my purposes and will be better for the end user as well, but thank you for the link to the function reference! I’ve been using http://codex.wordpress.org/Template_Tags as my only reference and was under the impression that was all there was to work with!

    Thread Starter yolise

    (@yolise)

    Can I impose on you kind people again?

    I’ve got this in my functions:

    ‘add_theme_support( ‘post-thumbnails’ );
    set_post_thumbnail_size( 250, 150, true );’

    but for some reason, when the plugin displays the thumbnail, it’s square. The function works for featured images, but doesn’t seem to set the default post thumbnail size. Have I missed something out in the function, perhaps?

    Moderator keesiemeijer

    (@keesiemeijer)

    Maybe this will help
    On line 64 of the plugin (taxonomy-images.php):
    private $detail_size = array( 75, 75, true );
    Change it to your dimensions:
    private $detail_size = array( 250, 150, true );
    I think you have to upload images again to make changes take effect.

    Thread Starter yolise

    (@yolise)

    Yes, that seemed to work (changing the tag argument to “detail” rather “thumbnail”).

    Thanks again!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Showing category images instead of names’ is closed to new replies.