Display a category name automatically using code in the functions.php file

Would each post only be in one category? You’d first need to get all the categories associated with the post, and then output only first. Here is an untested example: function add_before_content($content) { $post_cats = get_the_category(); return ‘<p>This post is in the ‘ . $post_cats[0]->cat_name . ‘ category</p>’ . $content; } add_filter(‘the_content’, add_before_content); Reference: http://codex.wordpress.org/Function_Reference/get_the_category

Get posts from 2 or more categories

The ‘category__in’ parameter accepts an array. You’re giving it a string of comma-separated values. Also, you need to use explode() instead of implode(). implode() is for joining array elements with a string, while explode() is for splitting a string by another string. Try this instead: $args = array( ‘category__in’ => array( explode( ot_get_option( ‘beautiful_categories’ ), … Read more

Lowest catagory link

Atlast done it fully $categories = get_the_category($post->ID); foreach($categories as $category) : $children = get_categories( array (‘parent’ => $category->term_id )); $category_link = get_category_link($children); $has_children = count($children); if ( $has_children == 0 ) { $name=$category->name; $category_link = get_category_link($category); echo “<a href=”https://wordpress.stackexchange.com/questions/161873/$category_link”>$name</a>”; } endforeach;