Kafkaesqui,
Thank you for this code;
<?php
global $post;
foreach(get_the_category($post->ID) as $category) {
echo $category->name . ',';
}
?>
How would you assign “echo $category->name . ‘ ‘;” to another variable so it could be used in another PHP function?
For example:
-If I have two cateogories: Stocks and Funds
-And the echo outputs: Stocks,Funds
-Can I assign this to antoher field like: $myWordpressCategory so $myWordpressCategory=”Stocks,Funds” and I can use this in another PHP function.
I’ve tried: $myWordpressCategory = $category->cat_name . ‘,’; but it only returns the last category.
Thank you,
Steve