As you are concatenating the result to a href you must wrap the ifelse statement inside another set of parentheses so the result is calculated first and then returned:
<a href="'.(($cat_id == 5) ? esc_url($custom_link) : esc_url($category_link)).'">
Related Posts:
- Display current category title on category page
- Inject post (from specific category) between posts in Loop
- retrieve thumbnail from post ID of best selling product in category
- Custom HTML structure in wp_list_categories
- Allow authors to post only in categories they create in WordPress
- List all categories but exclude current post category on single post page
- Categories Template Assistance
- Edit category output
- Error: array_map(): Argument #2
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- Custom Loop through category menu to include sub categories
- Different background-image by category
- Get posts with at least one category in common with current post?
- Woocommerce – remove product from category
- Get category name from custom loop and echo it once
- Display all categories including sub categories
- Custom category code not showing all posts
- hover image appears below placeholder instead of overlayed
- get current product name in functions.php
- How to use transient in this code for related post?
- Filter Select results based on selection
- What is an equivalent of single_cat_title for getting the slug of the category?
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- WP grandchild categories in nested ul li
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- Move category description below post list in blog
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- Setting default category base on theme activation
- Hide subcategories (widget)
- Let Users Choose Post Categories
- How to show only subcategories in parent category not parent category?
- how to show only specific category for a template
- Creating sub-categories via php
- Edit the_category (); for a hierarchical display
- How to array only one key from another array
- Displaying posts based on category
- How do I remove a category from a wordpress loop>
- Get categories names as an array to use it in theme settings
- How to get the last category name of a child category?
- Use get() method to grab all categories and output inside another method
- How to separate categories with commas?
- Show all tags within a category?
- Alphabetically Ordered Category in WordPress
- Output category list inside array
- Loading Posts & Category with Ajax
- How to get current category
- WooCommerce: Display product categories to make IF statement
- Trying To Get Child Categories To Show, Issue With foreach Loop
- Define category ID using get_post_meta
- Show parent categories of the current category
- How to check if a category has a parent and child categories?
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Get category id when SEO URL is turned on
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Display Sibling WooCommerce Product Categories on Archive Page
- display the months of a specific category
- I need to display posts in subcategory beside posts in main category
- Add Custom Category Description When Empty
- Order category posts by last word of custom field
- Add a product category to a specific product via a button
- List sub categories and corresponding posts of a parent category
- Dropdown category field inside repeatable metabox
- Get nice name of category from slug (remove dashes of category)
- How to Link to category titles if it is in the single post content?
- How can i show specific Category List?
- How to show category just on specific pages?
- How to filter specific element of an array in wordpress/php?
- All categories options or All categories not Populating
- PHP get_category() function redeclared
- List categories assigned to a post
- Unable to get Post Category Name and URL
- How to add style in functions.php depending on conditions?
- How do I display Category titles on a WP Page?
- problem with category menu, it doesn’t want to show link
- Saving category as insert post
- Trying to see if page is category or single and displaying title with appropriate heading tag
- !in_array doesnt recognize category
- get_category only returning details for ‘uncategorized’
- How to change links in the 3 main categories, on widget category, to a javascript function call
- how to set category name for a post
- category & sub category order issues in wordpress
- Hide empty categories from get_categories
- on category page get name of category as a string
- WordPress categories not working throughout site
- Fix incorrect related posts code snippet
- Display a list of posts corresponding to a category
- How to create categories out of a list of words?
- Get Products within Current Product Category
- Is there a way of displaying related posts from lowest hyrachical order (lowest child category to parent category)
- How to limit number of posts in the certain category and exclude the oldest post automatically
- child category under correct parent
- Display featured posts first, then display all others within a specific category in WordPress
- Can’t assign menu parent id or menu item breaks
- Prevent publishing of uncategorized posts