Using %postname% tag with a Custom Permastruct creates 400 Bad Request Errors from the server

Okay, I feel stupid.

I needed to translate %postname%. I thought it did so automatically since the admin page looked like it had but apparently if you do use custom permastructs, you have to translate even the default tags.

My solution: add this to my post_type_link filter:

$post = get_post($post_id);
$permalink =  str_replace('%postname%', $post->post_name, $permalink);

Problem solved.

Leave a Comment