WP Permastructure
Custom Structure Tag (1 post)

  1. DoctorWombat
    Posted 3 years ago #

    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:

    outputs to http://myblog.com/hello-world/the-post-title

    Custom post type permalink settings -> custom post type structure:

    outputs to http://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.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Permastructure
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic