• Hi – I’m hoping someone out there might be able to help me out with this please.

    I want to display categories as images on my homepage (ideally with latest posts below them) – the closest that I can find to what I’m looking to replicate is this website https://www.alpedhueznet.com

    Does anyone know of any plugin out there that will pull through my category featured images and let me display in this style with latest posts from the same category.

    Many thanks in advance,
    Chris

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Best way to write a template with category image and posts below.

    Here is an example of how template code should be

    <?php 
    $categories = wp_list_categories();
    foreach( $categories as $cat ): 
            $cat_thumb_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
           $img_url = wp_get_attachment_image_src( $cat_thumb_id, );
    ?>
    <div><img />" /><br/>
    <?php $query = new WP_Query( array( 'category_name' => $cat, 'posts_per_page' => '5' ) ); 
    echo '<ul>';
    if ( $query->have_posts() ) :
        while ( $query->have_posts() ) : $query->the_post();
            echo '<li><a href="'.the_permalink().'">';
      echo get_title();
      echo  '</a></li>';
        endwhile;
    else :
        echo '<li>No posts</li>';
    endif;
    echo '</ul></div>';
    endforeach; 
    wp_reset_query();
    • This reply was modified 7 years, 3 months ago by Ganesh Veer.
    • This reply was modified 7 years, 3 months ago by Ganesh Veer.
    • This reply was modified 7 years, 3 months ago by Ganesh Veer.
    • This reply was modified 7 years, 3 months ago by Steven Stern (sterndata). Reason: put code in backticks
    Thread Starter chrisjones78

    (@chrisjones78)

    Many thanks for that – I’ll take a look and see how I get on. Appreciate you taking the time

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help needed replicating this’ is closed to new replies.