• Ok i have homepage with 3 areas that i need to fill with my existing posts:

    • Main Featured area (1 post)
    • Featured area (3 posts)
    • Editors Picks (5 posts)

    Besides this 3 categories i have around 15 more and my site is blog based so i use archive pages a lot to list those posts.

    What was i doing before in situations like this is i would just create 3 more categories with names of my ares, and when i want to put some post in Featured area i just add it in that category and query it on my homepage.

    My problem now is that on single.php page i need to print category of posts and there should not be any of those 3 that i use for homepage.

    For example my posts is in Category “Boy Talks” and i want to put it in my Featured Posts area, so in my single post page i will get “Boy Talks Featured Posts”, but i need only “Boy Talks” there. I tried with this

    <?php
    $category = get_the_category();
    if ($category[0]) {
     echo '<a href="' . get_category_link($category[0]->term_id) . '"><h3>' . $category[0]->cat_name . '</h3></a>';
     }
     ?>

    And it gives me just first one in this case “Boy Talks” but problem is when my category is Weekend than word stars on W and it is behind Featured Posts so this code on top gives me “Featured Posts”.

    So my problem is how to hide those 3 from printing when i want to see cat of post?

    Or if you have another approach to show some of my existing posts and put them in those 3 areas on homepage please say.

    Thanks

    Alex

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Hide specific category from get_the_category’ is closed to new replies.