Speed up your Oxygen workflow

with Hydrogen Pack

A true Oxygens Editor Enhancer
Starts from $19.99

Display list of categories that are related to a particular post on your single page

<?php
	$categories = get_the_category();
		if($categories){
			echo '<div>';
			foreach($categories as $category) {
			echo '<span>' . $category->cat_name . '</span>';
		}
	echo '</div>';
}

?>

If you need just parent cagetory

Parrent

  • Child
  • Child
  • Child
<?php
  $perma_cat = get_post_meta($post->ID , '_category_permalink', true);
  if ( $perma_cat != null ) {
    $cat_id = $perma_cat['category'];
    $category = get_category($cat_id);
  } else {
    $categories = get_the_category();
    $category = $categories[0];
  }
  $category_link = get_category_link($category);
  $category_name = $category->name;  
?>                                   
<a href="<?php echo $category_link ?>"><?php echo $category_name ?></a>

If you need help with custom scripts or you are not skilled enough to implement something from the tutorial?

HIRE ME

Stay up to date with latest post and updates.