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;
Related Posts:
- Check if current category has subcategories
- wp_nav_menu not appearing for a couple pages
- wp_update_nav_menu_item() to insert categories
- How to get the url to tag & category base set by the user?
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- is_archive() content being shown instead of is_category()
- Retrieve all posts within tag OR category?
- Edit the markup of categories list
- New Theme creation
- How to get data about category in category.php
- editing fonts of category links from the_category() funtion
- How to check category of of custom post type or not
- Set a them for all subset of category
- How to call custom category field data in theme?
- Different templates for different category tags
- Why category.php throw 404 in wordpress while calling paginate_links()?
- Woo Framework: woo_cat_featured not populating
- Inside a loop, how to change CSS class based on category name?
- Question on using custom structures for categories
- Getting the category title / description returns first matching post?
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- Category page returns 404 error
- Show post categories
- Add description to categories menu in admin
- filter a loop base on specific category
- Problem with multiple loops in wordpress theme
- How to add icon over specific thumb
- How to differentiate the homepage structure from the category page structure in WordPress template?
- How to detect /category and /tag base pages?
- WooCommerce shared categories
- Show the number of the post
- Products category search not working
- In if…else condition, the else statement shows even if if statement is correct
- Can’t display posts by filtering categories using isotope.js
- Media Library Categories
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Change single.php template based on parent category
- Show posts from all categories
- If it is a top level category show children otherwise show sibling categories
- How to get multiple loop in category.php, my scripts becomes madness
- Category base 404 – fix
- altering theme – content generated by PAGES not PORTFOLIO
- Category Archives: Show posts categorized in parent category only
- WordPress 3.5 how to determine if user is on category listing or category edit screen?
- Display only one level subcategory in wordpress
- How can i hide the authors box from a specific set of categories and post types?
- Get all first images of posts in same category
- How to display the category featured images [closed]
- How to make /category/ URL load properly instead of 404 error?
- Display posts from the same category using next/previous post link
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- WordPress Multiple Category Search
- get all tags from category
- How can I add the featured image functionality to a custom taxonomy?
- WordPress and isotope filtering
- 5 blogs on one WordPress site
- Delete a specific category when deleting a user
- Show Previous/Next Posts navigation only inside the same category
- 404 error on subcategory pages
- Add line breaks in Category description via enter
- Filtering WordPress Contents based on URL
- Rewrite category slug
- View category in the preview of Theme Customizer
- Display only the latest post from multiple categories
- Get terms that are associated with products from current category
- Mass/Bulk assign categories to posts
- Sticky Posts Not Sticking to Top of Category Archive
- How to exclude categories from recent posts, recent comments & category widgets?
- hide specific categories from showing
- Category Search functionality on category metabox (wordpress admin)
- How to get category id in single.php wordpress?
- how do I filter single_cat_title to remove all instances of a particlular word
- Duplicate Category and Page URL loads Category instead of the Page
- Category page shows Oops! That page can’t be found
- get_query_var() and permalinks
- wp_nav_menu not highlighting the current category when viewing a single post
- How can I enable a TINYMCE rich text editor in the admin interface?
- WordPress order categories by ID
- ACF: Display category name using taxonomy field
- filter “inactive” categories from wp_list_categories?
- query order by category
- How to make 2 tag feeds show up on 1 page?
- Shortcodes not working in category or tag description
- Best way of getting WooCommerce category path
- Display the last post by each category?
- Post in multiple categories
- Order categories by name or view count
- Mod_Rewrite to show only last subcategory in URL
- wp_dropdown_categories() scripts working erratically on sidebar
- Access current post parent and sub category
- Give a page priority over a category that has the same name?
- Filter $cpt categories to omit certain category
- How to exclude the last post from a category(featured for example) from the main loop?
- How to rewrite the post URL according to the category?
- how do I exclude a category foreach
- CPT Custom post type Tags & Categories not showing for ‘Editor’ user in editor
- Trouble Fetching Posts Using WordPress API: No Response from Specific Category