1
votes

I'm currently working with a template (Point from MyThemeShop) in WordPress that has been functioning fairly well for me. I've already made some customizations but am having one issue.

The theme pulls the most recent posts and displays them in a "Featured Posts" area at the top of the page. I wanted more control over the posts displayed here so I set up a category (Homepage Featured Posts) to better define which posts should show up there. Works well, however, under this area where the recent post feed is . . . the thumbnail previews pull and display the category name in alphabetical order. So, if I have a featured post categorized under "Review" also, the preview thumbnail currently says "Homepage Featured Post" instead of "Review". I would like to exclude "Homepage Featured Post" from showing up in these thumbnails (and one other category I've also defined, "Trending Articles").

In the Index Template the code that seems to pull the category names is this:

<?php if ( has_post_thumbnail() ) { ?>
    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">
        <?php echo '<div class="featured-thumbnail">'; the_post_thumbnail('featured',array('title' => '')); echo '</div>'; ?>
        <div class="featured-cat"><?php $category = get_the_category(); echo $category[0]->cat_name;?></div>
        <?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'latestPost-review-wrapper'); ?>
    </a>

I've tried an exclusion method that sort of worked . . . but ended up not pulling ANY categories instead, using this method on line 4:

<div class="featured-cat"><?php $category = get_the_category(); echo $category[0]->cat_name !--'Homepage Featured Post';?></div>

Do I need to use specific category ID's? I am unsure how to accomplish this. Any help is much appreciated.

1

1 Answers

0
votes
<?php
    foreach((get_the_category()) as $cat) {
        if (    $cat->cat_name!=='Homepage Featured Post' || $cat->cat_name!=='Trending Articles' ) { 
            echo $cat->cat_name . ' ';
        }
    }
?>

Can you use above code.