This part of my script runs WordPress categories and displays them in a random order.
The problem I'm having is that the url is based upon the categories ID
There's one category that should go to a different page if clicked in stead of the categories page.
So I created a variable and kicked in the url. Created a if
-statement to see when the $cat_id
is loaded and then change it.
But it only outputs the url multiple times (every found category)
What can it be?
$category_link = get_category_link( $cat_id );
$custom_link = get_option( 'home' ).'/sub/sub-sub';
echo '
<div class="carousel_items">
<div class="category_image">
<a href="'.($cat_id == 5) ? esc_url($custom_link) : esc_url( $category_link ).'">
<img src="'.get_bloginfo('template_directory').'/images/svg/'.$cat_id.'.svg" />
</a>
</div>
</div>';
foreach
and it's outputting the$custom_link