WordPress.org

Forums

[resolved] category last 3 posts List with thumbnais (8 posts)

  1. redouanedev
    Member
    Posted 2 years ago #

    Hello everyone ! thank you for your help !
    i want add 2 boxes to the homepagge of the theme displayin the last 3 posts for a specefic categories that i want .just a post title with a thumbnail ( 60 x 60 px )
    this is the image explaining what i want exactley and thank you for your Help

    http://dl.dropbox.com/u/9421957/categoryPostList.jpg

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

  3. redouanedev
    Member
    Posted 2 years ago #

    thanks i tried but lot of coding oooh im beginner

  4. alchymyth
    Forum Moderator
    Posted 2 years ago #

    what theme are you using?

    can you post a link to your site to illustrate what you have so far?

    have you tried to use the forum search?
    similar problems have been asked and solved before.

  5. redouanedev
    Member
    Posted 2 years ago #

    i use silverOrchid theme from gazpo
    and i want change the loop with boxes each one for a specefic category with 3 or x latst posts with thumbnails 60 x 60 .
    i use a localhost as a server web . thank you for your help

  6. alchymyth
    Forum Moderator
    Posted 2 years ago #

    per category, try this general structure (you will need to add more html tags and css classes for easier formatting; posts are output as an unordered list):

    <?php $catname = 'what-ever-cat-slug';
    $cat_query = new WP_Query( array(
     'posts_per_page' => 3,
     'category_name' => $catname,
     'meta_key' => '_thumbnail_id'
    ));
    if( $cat_query->have_posts() ) :
     $cat = get_term_by('slug',$catname,'category');
     echo $cat->name;
     echo '<ul>';
     while( $cat_query->have_posts() ) : $cat_query->the_post();
      echo '<li>';
      the_post_thumbnail(array(60,60));
      echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
      echo '</li>';
     endwhile;
     echo '</ul>';
    endif; wp_reset_postdata();
    ?>

    (untested)

    make a backup copy of your theme before editing.

  7. redouanedev
    Member
    Posted 2 years ago #

    woow alchymyth ! worked so greaaaaaaaaaaat ! thank youuuuuuu

    and to add a expect text post ?

  8. redouanedev
    Member
    Posted 2 years ago #

    THANKS FOR YOUR HELP , SOLVED !

Topic Closed

This topic has been closed to new replies.

About this Topic