How it is possible to display only the parent category of the post. It contains two sub categories and I want to eliminate it.
Example:
myblog.com/parent_category/post_name
This is only what I want.
How it is possible to display only the parent category of the post. It contains two sub categories and I want to eliminate it.
Example:
myblog.com/parent_category/post_name
This is only what I want.
You must be logged in to post a comment.
You can try out this code here using
post_link
filter hook.This filter is applied to the permalink URL for a post prior to returning the processed url by the function
get_permalink
. Now we are modifying that to suit our requirement i.e, to display only parent category for the child categories and then followed by the post name.