• I’m writing a plugin to list media post types within the context of a page using a shortcode.

    This is what I have so far for “my-plugin” (for example):

    * shortcode named “my-list”
    * page called “my-page” containing “[my-list]” to use the shortcode
    * post in “my-list” CPT page called “my-post”

    When I go to “my-page” to see “my-list” generated, it lists “my-post” on the page with a link to “/my-page/my-post”. When I click on the link, it goes to “/my-plugin/my-post” (which makes sense).

    What I would like is for it go to “/my-page/my-post”. In fact, if it’s not complicated, what I really want is for it to go to “/my-page/%year%/%month%/my-post”.

    Just to clarify. When I go to “my-page” which uses “my-list” shortcode, I want to see the listing of links I created use the permalinks rules for where the posts are. In other words, when I use WP_Query and generate a listing using get_page_link(get_the_ID()), how can I have this link be the rewrite rules link in the form of “/my-page/%year%/%month%/my-post”?

    The most promising post to address this was this:

    https://vocecommunications.com/blog/2010/11/adding-rewrite-rules-for-custom-post-types/

    The only thing is that this seems overly complicated for what I want.

    Is there a better answer to this?

    I don’t know why this is so complicated for me.

    Maybe the reality is that I don’t understand what is going on in WP when custom post types are looked up and associated with the rules for generating permlinks

    Any help here would be greatly appreciated.

  • The topic ‘Permalinks/ReWrites for plugin using shortcode and CPT’ is closed to new replies.