WordPress.org

Support

Support » Plugins and Hacks » Hacks » Using the CPT slug in custom rewrites

Using the CPT slug in custom rewrites

  • I have this rewrite rule

    add_rewrite_rule('category/([^/]*)/feed/([^/]*)/([^/]*)/?',
    	    'index.php?category_name=$matches[1]&feed=$matches[2]&post_type=$matches[3]',
    	    'top');

    It uses the ID of the post type, rather than the post type slug. I’ve dug around and can’t find a way around this.

    For example, for post type “Bar None” with the id “bar_none” and slug “bar-none”.
    site.com/category/foo/feed/rss2/bar-none/ doesn’t work
    site.com/category/foo/feed/rss2/bar_none/ does

    site.com/bar-none/ works
    site.com/bar_none/ doesn’t

    So what intermediary step am I missing the get the slug to work in the rewrite URL?

  • The topic ‘Using the CPT slug in custom rewrites’ is closed to new replies.