Support

Account

Home Forums General Issues create a permalink structure with custom taxonomies and custom field Reply To: create a permalink structure with custom taxonomies and custom field

  • There are 2 ways that I can think of to do this.

    First the hard way

    The first thing you’re going to need to do is to create custom rewrite rules https://codex.wordpress.org/Rewrite_API/add_rewrite_rule

    The next thing you’ll need to do is create a pre_get_posts filter to alter the query based on those rewrite rules https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

    And finally you will need to create a filter to alter all of the permalinks for the taxonomy or post type, whatever it is that %sku% in /%custom-post-type%/%custom-taxonomy%/%sku%/ represents.

    Then the easy way

    Create an acf/save_post filter https://www.advancedcustomfields.com/resources/acfsave_post/ and in this filter get the value of the sku field and update the post slug to match this value. The problem with this is the you need to make sure that the value entered for sku is unique. I have outlined how to do this here https://support.advancedcustomfields.com/forums/topic/accept-only-unique-values/