Help Calling for a Function in the Loop
-
I’ve been having lots of difficulty trying to get this icon to display by the newest added post title without much progress.
The Loop:
<?php $the_categories = get_the_category(); if(function_exists('get_cats_icon($the_categories)')) { $screen = get_cats_icon(); $screen = $screen[0]; } ?> <img src="<?php echo ($screen); ?>" width="33" height="33" alt="" />
The Functions:
function get_cats_icon($the_categories) { foreach( $the_categories as $category) { if ($category->cat_name == "Category Title") { echo '<a href="https://site.com/category/title"><img src="https://site.com/wp-content/uploads/icon.png" /></a>'; } elseif ($category->cat_name == "Category Title") { echo '<a href="https://site.com/category/title"><img src="https://site.com/wp-content/uploads/icon.png" /></a>'; } } }
Is there any easy way to get this code to work?
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Help Calling for a Function in the Loop’ is closed to new replies.