Home Forums General Issues ACF Relationships in Custom Post Type Permalink


ACF Relationships in Custom Post Type Permalink

  • My problem is one that i can’t seem to find a solution to.

    I have 2 Custom Post Types, Mangas and Chapters, every chapter published will always be connected to a manga via the ACF relationship field.

    The current permalink structure for the chapter is and what i want is

    Since wordpress doesn’t offer much in the way of post-to-post relationships, the ACF relationship field is great for this and i have everything figured out except for this… the permalink.

    Any help would be appreciated. Please bear in mind that i don’t want to use an extra plugin for this.

  • Hi,

    In cases like you, unfortunately the nature of wp’s url, you gonna have to add the rewrite rule yourself.

    You can have a look at add_rewrite_rule.

    So, your code will look something like:

    function custom_rewrite_basic() {
        add_rewrite_rule('^mangas/([^/]*)/([^/]*)/?', 'index.php?chapters=$matches[2]', 'top');
    add_action('init', 'custom_rewrite_basic');


  • Oh, forgot one more thing.

    remember to go to the backend, Settings->Permalink and click save. so your custom rewrite rule will be saved.


  • Hello,

    you can do it without adding any permalink structure via hooks using the plugin:

    and use any custom post field generated by ACF in URL permalink.


Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘ACF Relationships in Custom Post Type Permalink’ is closed to new replies.