WordPress.org

Ready to get started?Download WordPress

Forums

Show thumbnails w/links to posts in a specific category (5 posts)

  1. slammedgraphics
    Member
    Posted 3 years ago #

    Hi. I need some help on a subject I've been researching for quite a while today and I haven't quite found the help I need for this specific attribute.

    Here's what I'm trying to do:

    I have a section at the top of the page where I'd like to display four thumbnails that link to posts in a specific category, like a featured categories section but without a jquery sliding function, just four thumbnail images that will link to their respective posts that are from a category that will be called featured.

    How can I accomplish this? I've tried several methods rather unsuccessfully. Any help would be greatly appreciated. :)

    Thank you.

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    check these functions in the codex:

    get_posts()
    http://codex.wordpress.org/Template_Tags/get_posts

    query_posts()
    http://codex.wordpress.org/Function_Reference/query_posts

    the_permalink()
    http://codex.wordpress.org/Function_Reference/the_permalink

    the_post_thumbnail()
    http://codex.wordpress.org/Function_Reference/the_post_thumbnail

    i could also help if you can describe the unsuccessful attempts

  3. slammedgraphics
    Member
    Posted 3 years ago #

    I tried something similar to what is described here.

    http://wordpress.org/support/topic/only-show-post-thumbnails-for-one-category?replies=5

    Obviously for my application it would not be going in the footer. It will be inside a divider labeled featuredarea

    It seemed like I was on the right track but now I"m just lost. I'll check out the above links. If you have any input/ideas feel free to let me know. Thanks so much.

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    the other thread had a few typos (my mistake)- this should work:

    <?php
    $header_thumbs = get_posts('category_name=Featured&posts_per_page=4');
    if( $header_thumbs ) :
      foreach( $header_thumbs as $header_thumb ) {
      setup_postdata($header_thumb);
      echo '<a href="' . get_permalink($header_thumb->ID) . '">' . get_the_post_thumbnail($header_thumb->ID) . '</a>';
      }
    endif;
    ?>

    make sure the spelling (capital letters and so) of your category name (instead of Featured) is right.

  5. allthewhile
    Member
    Posted 3 years ago #

    Alchymyth,

    Thanks for your support on this issue.

    I'm trying to do almost exactly what slammed is doing. When I insert your code into my theme it returns full sized images and not thumbnails. Any help with this would be appreciated.

    -jayson

Topic Closed

This topic has been closed to new replies.

About this Topic