the_category if/else statement

Is the code used inside of the loop? The following code should work: if ( class_exists( ‘DPortfolio’ ) ) { echo DPortfolio::instance()->dportfolio_get_category(); }else{ the_category(); //or echo get_the_category(); } If outside of the loop you can try echo get_the_category( $post_id ) to show the categories. Note: As you are getting an error, if you edit the … Read more

Display the category name of a post that is in two different categories

This should get you going in the right direction. echo ‘<div class=”testata_inner”>’; $cat = get_the_category($recent[“ID”]); //get the category array if ($cat[0]->name != “Featured”) { //check if the category is “featured” $catname = $cat[0]->name; //set $catname variable to “featured” } else { $catname = $cat[1]->name; //or set $catname variable to “other category name” } echo ‘<span … Read more