get_category('91')
is always going to return an object of category ID 91’s data. This means your if statement is always going to return as true. You need to get the current iterated posts assigned category ID and then check if it is 91.
<!-- Return objects of current iterated posts associated categories -->
$categories = get_the_category();
<!-- Get current iterated posts assigned category ID from $categories object. The [0] is because a post can be assigned to multiple categories.
In your example you are probably only assigning one category per post, so you just need to grab the ID of the first category in the returned object. -->
$category_id = $categories[0]->cat_ID;
<!-- Check if current iterated assigned posts category ID is equal to 91 -->
<div class="bfa-category <?php if ($category_id == 91) echo 'bfa-cat-s1'; ?>">
<?php the_category(); ?>
</div>
Related Posts:
- Inject post (from specific category) between posts in Loop
- User Defined order on get_categories?
- Custom Loop through category menu to include sub categories
- How to exclude specific category from the get_the_category(); array
- Filter Select results based on selection
- Alert Bar section within WP loop is displaying even though there are no posts
- Display category name only once inside loop
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- How do I remove a category from a wordpress loop>
- How to get the last category name of a child category?
- How to get current post category details inside “loop”?
- Problem with custom loop and wp_list_pluck [closed]
- Do not duplicate posts with multiple categories in multiple loops
- Return to the beginning of the results of a for loop
- Exclude category and post from loop in custom category.php
- Error trying import one category on page
- Remove the_content From Loop
- Displaying post per day
- How to add active class to custom menu using while loop and wp_list_pages
- How to Populate the list of custom post type categories
- Php string not working in WordPress Functions.php [duplicate]
- Print html when custom field has value inside while loop
- Categories Template Assistance
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- When would you use $_post instead of $post?
- How do I display the function the_content in this loop?
- How to get to a specific position in wp_query?
- Facebook “like” open graph meta in header.php
- Custom category code not showing all posts
- Using foreach loop breaks
- Loop with slider (slider not loading)
- How to hide all child pages with post_query?
- How to sort posts based on the value (number) of a post’s metadata?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Displaying Woocommerce Product Category in WordPress
- How can I add extra word in permalink when someone click download button?
- Woocommerce : Can’t get product info in loop
- Let Users Choose Post Categories
- Checkbox doesn’t stay checked, conten
- Can we count the WordPress Loop
- Display most popular posts of category
- get taxonomy thumbnail and use it as a variable in code
- Display an image if odd number of posts in grid
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Last class on last headline?
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- Only show size attributes in product box woocommerce when available
- Argument for if term-> have child?
- Calling function in loop causes repeat data
- WordPress call post-ID in jquery
- How to Generate a list of Most Commented post?
- How to pick “full/thumbnail” images in the loop?
- How to Fix an Archive.php That Displays All Posts?
- is user member of a group, show them categories [closed]
- How to add ASCII symbol after each recent post [closed]
- Using multiple variables to assign categories to an array
- Search.php gets metadata from first post
- the_post(); prints out style text into my HTML?
- Pagination at category doesnt work with same name of page
- display the months of a specific category
- Child-Theme Category View with modified permalinks (%category% removed)
- update_user_meta as multiple value but with same meta key
- How to move a post from one category to another
- Create category after theme setup and modify the default one
- Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)
- WordPress Recent Posts – Loop
- ACF background-color per post in a WordPress loop
- Advertisement in Loop Posts wordpress
- Displaying 3 Category Posts differently
- Adding custom PHP to existing loop in Genesis
- How to Pass Current Taxonomy Terms into new WP_Query?
- How to list categories by page id in wordpress
- For each 3 posts, show a different post type
- WordPress using get_term to retreive slug not working as expected
- Showing the project type in HREF
- Loop returns more items than exist?
- How do I display Category titles on a WP Page?
- Modify category archive page loop on functions.php
- Front end post submissions do not get submitted in the category
- WP_Post is not from correct array
- Post formating on Home page
- divide custom field values in div every two values
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Saving category as insert post
- Limit ads appearing more than three times
- Trying to exclude posts from a category on the home page
- Pagination on Custom Loop
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- What is the best way to get the first few post from WordPress in different divs using a loop?
- Custom single.php files for different post formats
- Troubleshooting “loopback requests that take too long”
- on category page get name of category as a string
- WordPress categories not working throughout site
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Loop on a wordpress Page instead of content coming from the WP text editor
- Help with if/else loop [closed]
- Exclude a category ID from the following function
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress