[Plugin: WP Permastructure] Custom Structure Tag
-
Thank you for the great plugin. I’ve run into an issue that I was hoping to get some insight into.
I’m trying to create a custom structure tag %postparent% for the permalink settings. Here is the code I have in my functions.php:
add_filter('post_link', 'post_parent_permalink', 10, 3); add_filter('post_type_link', 'post_parent_permalink', 10, 3); function post_parent_permalink($permalink, $post_id, $leavename){ // the code here will eventually determine the post's parent slug $slug = 'hello-world'; return str_replace('%postparent%', $slug, $permalink); }
If I put %postparent% into the regular WordPress’s custom structure (Under Settings->Permalinks->Common Settings), it works, and I see “hello-world” in my URL.
However, if I try to put %postparent% into one of my custom post-type structure fields (the ones generated by WP Permastructure), all I get in the URL is %postparent% .
So to reiterate:
Common Settings -> custom structure:
/%postparent%/%postname%
outputs to https://myblog.com/hello-world/the-post-title
Custom post type permalink settings -> custom post type structure:
/%postparent%/%postname%
outputs to https://myblog.com/%postparent%/the-custom-posttype-post-title
I’m just wondering if this an issue with the plugin not recognizing the filters I’ve placed. Any help would be greatly appreciated. Thanks.
- The topic ‘[Plugin: WP Permastructure] Custom Structure Tag’ is closed to new replies.