Skip to main content
added 505 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

I'm using a custom permalink structure:

/%category%/%postname%/

So that my posts are listed like:

mysite.com/widgets/blue-widget

This works fine as long as "blue-widget" exists in one and only one category. However, when it appears in more than one category, like perhaps a child of uncategorized, the resulting URL becomes:

mysite.com/uncategorized/child-of-uncategorized/blue-widget

Even though the post is still in "widgets", it appears that there is something that makes uncategorized trump it. I believe its because it has the lower id.

I need to know if its possible to exclude uncategorized and any children of uncategorized from appearing in the permalink structure.

UPDATED EXAMPLE:

So, if a post is in 3 categories for example:

Widgets (parent_id=0), Uncategorized (parent_id=0), Child of Uncategorized (parent_id=1)

I want the filter to use "Widgets" as the permalink slug and exclude "uncategorized" and all of its children.

If the post is in 2 or more categories that are not uncategorized or a child of uncategorized, then just use the newest category as the permalink slug.

If the post is assigned solely to uncategorized or one of its children, then do not display a category slug permalink

I'm using a custom permalink structure:

/%category%/%postname%/

So that my posts are listed like:

mysite.com/widgets/blue-widget

This works fine as long as "blue-widget" exists in one and only one category. However, when it appears in more than one category, like perhaps a child of uncategorized, the resulting URL becomes:

mysite.com/uncategorized/child-of-uncategorized/blue-widget

Even though the post is still in "widgets", it appears that there is something that makes uncategorized trump it. I believe its because it has the lower id.

I need to know if its possible to exclude uncategorized and any children of uncategorized from appearing in the permalink structure.

I'm using a custom permalink structure:

/%category%/%postname%/

So that my posts are listed like:

mysite.com/widgets/blue-widget

This works fine as long as "blue-widget" exists in one and only one category. However, when it appears in more than one category, like perhaps a child of uncategorized, the resulting URL becomes:

mysite.com/uncategorized/child-of-uncategorized/blue-widget

Even though the post is still in "widgets", it appears that there is something that makes uncategorized trump it. I believe its because it has the lower id.

I need to know if its possible to exclude uncategorized and any children of uncategorized from appearing in the permalink structure.

UPDATED EXAMPLE:

So, if a post is in 3 categories for example:

Widgets (parent_id=0), Uncategorized (parent_id=0), Child of Uncategorized (parent_id=1)

I want the filter to use "Widgets" as the permalink slug and exclude "uncategorized" and all of its children.

If the post is in 2 or more categories that are not uncategorized or a child of uncategorized, then just use the newest category as the permalink slug.

If the post is assigned solely to uncategorized or one of its children, then do not display a category slug permalink

Tweeted twitter.com/#!/StackWordPress/status/431239056882958336
added 43 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

I'm using a custom permalink structure:

/%category%/%postname%/

So that my posts are listed like:

mysite.com/widgets/blue-widget

This works fine as long as "blue-widget" exists in one and only one category. However, when it appears in more than one category, like perhaps a child of uncategorized, the resulting URL becomes:

mysite.com/uncategorized/child-of-uncategorized/blue-widget

Even though the post is still in "widgets", it appears that there is something that makes uncategorized trump it. I believe its because it has the lower id.

I need help to figure out howknow if its possible to exclude the uncategorized cat and any children of uncategorized from appearing in the permalink structure.

I'm using a custom permalink structure:

/%category%/%postname%/

So that my posts are listed like:

mysite.com/widgets/blue-widget

This works fine as long as "blue-widget" exists in one and only one category. However, when it appears in more than one category, like perhaps a child of uncategorized, the resulting URL becomes:

mysite.com/uncategorized/child-of-uncategorized/blue-widget

Even though the post is still in "widgets", it appears that there is something that makes uncategorized trump it.

I need help to figure out how to exclude the uncategorized cat and any children from appearing in the permalink structure.

I'm using a custom permalink structure:

/%category%/%postname%/

So that my posts are listed like:

mysite.com/widgets/blue-widget

This works fine as long as "blue-widget" exists in one and only one category. However, when it appears in more than one category, like perhaps a child of uncategorized, the resulting URL becomes:

mysite.com/uncategorized/child-of-uncategorized/blue-widget

Even though the post is still in "widgets", it appears that there is something that makes uncategorized trump it. I believe its because it has the lower id.

I need to know if its possible to exclude uncategorized and any children of uncategorized from appearing in the permalink structure.

Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

How to exclude uncategorized from permalink structure /%category%/%postname%/

I'm using a custom permalink structure:

/%category%/%postname%/

So that my posts are listed like:

mysite.com/widgets/blue-widget

This works fine as long as "blue-widget" exists in one and only one category. However, when it appears in more than one category, like perhaps a child of uncategorized, the resulting URL becomes:

mysite.com/uncategorized/child-of-uncategorized/blue-widget

Even though the post is still in "widgets", it appears that there is something that makes uncategorized trump it.

I need help to figure out how to exclude the uncategorized cat and any children from appearing in the permalink structure.