WordPress.org

Ready to get started?Download WordPress

Forums

Using the CPT slug in custom rewrites (1 post)

  1. Rebecca Schaefer
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.