I’m running the latest version of WordPress with pretty permalinks enabled.
I’m looking for a way to include the Post Format type (eg: link, status, quote) in the post’s permalink. When the post has no format assigned, or uses the ‘standard’ format, I want that part of the permalink to empty.
Example using the link post format:
http://example.com/link/look-at-this-cool-site/
Example using the quote post format:
http://example.com/quote/example-quote-post
Example using no post format:
http://example.com/just-another-post
Edit: See my answer for progress
While researching this topic myself, I found a plugin called Post Format Permalink. However, this plugin is not compatible with recent versions of WordPress; it is also filled with unnecessary code.
I forked the plugin’s repository on GitHub, and improved the code greatly. I can now use a
%post_format%
tag in my permalink structure, and that works fine. Mostly.The problem is, posts with no post format are displaying as
http://example.com/standard/just-another-post
, which is not the desired outcome. I’ll keep working on this, and post an update here.Here is the code I used. It can also be found on GitHub:
You can add a custom slug to the permalinks via plugin and use this inside your custom permalinks; dont forgett to update the permalinks. It is important, that the rules was refreshed. The follow source is a exmaple for use post format with the string
%postformat%
, but not perfectly code. Better is to load on hookplugins_loaded
and not create a new class, but enough to test and use it now.Please check this, current untested. I have write this for long time.