• Hi all.

    I have a custom post type that has a slug of /mycustompost/%author%/%post_id% which is all working however I want to be able to display a list of posts if someone browsers to /mycustompost/%author% which will then display the custom posts relevant to that author, could someone advise how I would intercept this ?

    Thanks
    Paul

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You need a rewrite rule that takes your desired permalink and rewrites the permalink into a form that’s compatible with the default WP query parser. See Rewrite API/add rewrite rule

    As an example, if your permalink is example.com/my_cpt/madladuk, you would want the rewrite rule to change that to example.com/index.php?post_type=my_cpt&author=madladuk

    The index.php URL format above (modified for your situation) should return the desired posts right now without any modification to your site at all. If not, further modifications beyond the rewrite rule will be needed, probably involving Plugin API/Action Reference/pre get posts

    Note that I currently have spotty Internet access and may not be able to respond to further questions for some time. I hope this alone is of some help. Good luck!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom post type and permalinks’ is closed to new replies.