WordPress.org

Ready to get started?Download WordPress

Forums

Category Archive Thumbnails (1 post)

  1. ddeuster
    Member
    Posted 1 year ago #

    http://www.host4eighty5.com/think-on-these-things/

    I'm working on a page that will have a category list page as seen above. I am looking to have a thumbnail associated with the post and have that thumbnail also be the featured image on the single post.

    Also having an issue with the code I'm using displaying an extra
    li on the output. Below is the code.

    <?php
    // Grab the categories - top level only (depth=1)
     $get_cats = wp_list_categories( 'echo=0&title_li=&depth=1' );
    // Split into array items
     $cat_array = explode('</li>',$get_cats);
    // Amount of categories (count of items in array)
     $results_total = count($cat_array);
    // How many categories to show per list (round up total divided by 5)
     $cats_per_list = ceil($results_total / 5);
    // Counter number for tagging onto each list
     $list_number = 1;
    // Set the category result counter to zero
     $result_number = 0;
    ?>
                            <ul class="bulletin-list" id="cat-col-<?php echo $list_number; ?>">
    
        <?php
            foreach($cat_array as $category) {
            $result_number++;
    
            if($result_number % $cats_per_list == 0) {
            $list_number++; ?>
            <li>
                            	<div class="bulletin-thumb-out">
                                	<div class="bulletin-thumb">
    
                                    </div>
                                </div>
                                <h3><?php echo $category; ?></h3>
    
            </li>
            <?php
            '<ul class="bulletin-list" id="cat-col-'.$list_number.'">';
    
      }
    
        else { ?>
    
            <li>
                            	<div class="bulletin-thumb-out">
                                	<div class="bulletin-thumb">
                                    </div>
                                </div>
                                <h3><?php echo $category; ?></h3>
    
            </li>
    
            <? }
    
        } ?>
    
    </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic