Support » Fixing WordPress » Displaying featured images specific to category dynamically

  • Resolved theplastickid

    (@theplastickid)


    Ok so on my home page I have the following PHP pulling in my featured images from all categories:

    http://pastebin.com/y2QCWRJX

    When I click on a category page however is there a way to display only the featured image specific to the category that I click and do this dynamically.

    Or would I need to create custom category pages (category-slug.php) and use similar PHP to that I am already using on my home page, specific to category ID or something similar.

    Appreciate any help.

    Many Thanks,
    Brett.

Viewing 9 replies - 1 through 9 (of 9 total)
  • try and change from:
    $the_query = new WP_Query('showposts=&orderby=post_date&order=desc');
    to:

    if( is_category() ) :
    $the_query = new WP_Query('showposts=&orderby=post_date&order=desc&cat='.get_query_var('cat'));
    else : $the_query = new WP_Query('showposts=&orderby=post_date&order=desc');
    endif;

    (untested)

    Thread Starter theplastickid

    (@theplastickid)

    Think that’s almost there only its only pulling in one featured image. The latest post.

    Thread Starter theplastickid

    (@theplastickid)

    Anyone? Any ideas?

    possibly try to set the ‘showposts’ to whatever number you want to show:

    if( is_category() ) :
    $the_query = new WP_Query('showposts=9&orderby=post_date&order=desc&cat='.get_query_var('cat'));
    else : $the_query = new WP_Query('showposts=9&orderby=post_date&order=desc');
    endif;
    Thread Starter theplastickid

    (@theplastickid)

    Still no luck, it seems to be just loading my most rescent post.

    Here is a paste bin can you see if I’ve made any errors? I did just copy and paste.

    http://pastebin.com/201T76aR

    Thread Starter theplastickid

    (@theplastickid)

    Still have not found a solution to this 🙁

    change this section:

    <div class="latest-post">
    
                                       <a href="<?php the_permalink() ?>" rel="bookmark">
                                         <?php the_post_thumbnail('latestvideos'); ?></a>
    </div>

    to:

    <?php if( $the_query->have_posts() ) : while( $the_query->have_posts() ) : $the_query->the_post(); ?>
                                     <div class="latest-post">
    
                                       <a href="<?php the_permalink() ?>" rel="bookmark">
                                         <?php the_post_thumbnail('latestvideos'); ?></a>
    </div>
    <?php endwhile; endif; ?>

    Thread Starter theplastickid

    (@theplastickid)

    Magic works perfectly. Thanks alchymth you have some skills!

    this is nice . i have one more thing to know

    how can i specific category and how can show only thumbnail size.

    i want to show specify category post feature images display

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Displaying featured images specific to category dynamically’ is closed to new replies.