Yes, that is the line you need to edit, and you need to check and see if the current post is within your specified category. So you could replace that line with this code and it should do the trick:
if(in_category(90)) {
$author = mom_option('post_meta-author') == 1 ? '<span class="author vcard" itemprop="author" itemscope itemtype="https://schema.org/Person">'.__('Posted By:', 'theme').' <span class="fn" itemprop="name"><a href="'.$author_link.'">'.get_the_author().'</a></span></span>': '';
} else {
$author="";
}
If that doesn’t work, either you have the wrong category ID, or the post object isn’t getting set correctly at this point (i.e. you aren’t in the loop).
Also note: you don’t have to use the category ID, you can use the slug or name if you want it to be more readable code.
Related Posts:
- Checklist of selected categories
- Is it possible to disable certain user roles from creating tags?
- How to set up sub-categories for author pages?
- Custom query with category exclusion and post-meta “whitelist”
- How to make a relationship between books and authors?
- Root level category, tag, author and archive pages to work
- How to have a static category/author page?
- Automatically assign posts by author to a specific category
- Search by word, category, tag, author
- How to group the loop posts in a particular by author?
- How to control template resolution if both Author and Category filter in place?
- Hide post meta data on a specific category
- Display posts separated by Category in Author’s page
- How to display singular form of category name?
- Restrict author to create subcategory in a selected category
- Add /category/ to an author archive page
- get_post_meta not working on category.php
- Hidde certain category from post meta
- How to conditionally hide author name on Single.php if category is “news”, otherwise if category is something else display author name?
- Is there a way to only show Custom Meta Data on single posts from certain catagories
- Author Page – List of categories plus number of posts in that category
- How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?
- Post by category+author not working!
- Display Related Posts by “Category” “by Author”
- Get Meta Keys of Custom Categories
- Custom meta boxes ID prefix showing on first category but not others
- what file I need to create to work date archive links?
- Assign author to category and not only posts
- Sending all categories associated with a post to Google Ad Manager for use with .setTargeting
- Assignt automatically two categories by author
- How to fetch common posts from two feeds?
- Remove “Category:” from Post meta
- Displaying data from custom fields on a specific category page
- Please tell how to stop the category from showing up on posts
- how to get postmeta info based on multiple categories?
- Assign a category to all articles
- How do you add Author and date Published on Category Pages?
- how to Specifies an author / editor to edit one category only?
- How can I hide the category term for posts with none set?
- Hide all posts by an author
- Archives and category of authors
- How can i hide the authors box from a specific set of categories and post types?
- How to display posts by author in a separate page, other than author.php?
- Limit authors on specific catogories
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Is There a Difference Between Taxonomies and Categories?
- List all subcategories from category
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get Category ID inside Category template
- Only one category per post
- WordPress Multisite – global categories
- Get the children of the parent category
- Get posts from sites in Multisite?
- WP REST API: filter by category 1 AND category 2
- How To Get Parent Category Slug of Current Post
- Display All Products by Category with WooCommerce
- What is the difference between a “tag” and a “category”?
- Is there an easy way to make a meta box have the tabs like the Categories meta box has?
- How to check if I’m on the last page of posts?
- Display posts from the same category using next/previous post link
- How would I get a taxonomy/category list inside a Gutenberg block?
- Can I set a default featured image for a category?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- Force category choice before creating new post?
- Gutenberg editor add a custom category as wrapper for custom blocks
- WooCommerce: List All Categories
- How to get category and archive title?
- Get category ID from category slug (not working)
- How do I remove “Uncategorized” from posts with more than 1 category?
- How to add category to: ‘wp-admin/post-new.php’?
- Get rid of WordPress category, tag and author archives?
- Individual rss feed entry length for categories?
- How can I create a category landing page followed by pages of posts?
- Remove parent category from permalink? Basically only have the child category?
- Custom permalink structure leads to be 404 on pagination
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- Posts URL structure like site.com/category/the-post-title
- Can’t custom taxonomies have same terms (slugs) as categories?
- How to get permalinks with category base working with sub-categories
- How to remove the term “category” from category pagination?
- Using wp_category_checklist in a widget
- WP 3.9 TinyMCE no longer loads on category description editor
- On the category page, get the category object
- Get only the top level categories using get_categories() without foreach loop
- Get all categories and posts in those categories
- How to add featured image for category (without a plugin)?
- How to create a custom sort for WordPress categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Category archive by year with permalink support /category/YYYY
- Best Way to Redirect Category to Page and Hide Category
- get_terms vs. get_categories: does it matter?
- What is a good robots.txt?
- Allow users to create their own feed from selected categories?
- Hook when category is added to post
- get_categories for custom post type with a specific custom taxonomy attached
- Add a URL prefix to permalinks of one category of posts only
- How do you add categories to custom post types in WordPress?
- Create a category list page