• Hello,

    I am using the following code to show all the categories the blog entry is linked to.

    <?php foreach((get_the_category()) as $cat) { echo ‘<tr><td>cat_ID . ‘”>’ . $cat->cat_name . ‘</td></tr>’; } ?>

    My horse blog has over 200 categories and I want to reduce the number of shown categories at a blog entry. For exeample:
    My entry is connected to the categories 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10. Is there possible that just the categories 3-8 are shown within my blog entry altought this entry is linked to more categories?

    Please help me guys!!!
    Jenny

Viewing 5 replies - 1 through 5 (of 5 total)
  • So you want the above code to *only* display categories 3 through 8 (whichever ones a post is linked to), at all times? This should do it:

    <?php
    foreach( get_the_category() as $category ) {
        if( ($category->cat_ID > 2) && ($category->cat_ID < 9) ) {
    	    echo '<tr><td><a href="' . get_category_link($category->cat_ID) . '">' . $category->cat_name . '</td></tr>';
    	}
    }
    ?>

    (Categories listed in tables? Really?)

    Thread Starter jenny86

    (@jenny86)

    THAAAANKS, WORKING FANTASTIC!!

    Kafkaesqui, can you make that code to put the cat ID´s that we want to include? Always… 🙂

    This dont work for me because my category IDs is a mess…
    For example, I want to include always: 3422, 3423, 3424, 3425, 3438, 3426, 3427, 3428, 3429, 3430, 3431, 3431, 3432, 3433, 3440, 17, 18, 19, 20, 3436, 3437, 21, 22, 23, 2239, 24, 2240, 490, 3420, 25, 3439

    Please, anyone?

    *BUMP* 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Delimit number of linked categories’ is closed to new replies.