The one issue I see immediately with your rewrite rule is this part:
index.php?pagename=charities
You don’t have a page named “charities”, you have a custom post type, so that should be:
index.php?charities=$matches[1]
assuming your custom post type query var is charities
.
HOWEVER, that said, I would not add rewrite rules for this, WordPress will take care of much of the heavy lifting if you use add_rewrite_endpoint
instead:
add_rewrite_endpoint( 'contacts', EP_PERMALINK );
add_rewrite_endpoint( 'donation-info', EP_PERMALINK );
add_rewrite_endpoint( 'comments', EP_PERMALINK );
After adding these and flushing rewrites, you will be able to check if the contacts
, donation-info
, and comments
array keys exist in $wp_query->query_vars
.
Related Posts:
- Post URL based on Custom Post Types variables
- Custom post type permalink returns 404
- Use the same date-based permalink structure for all post types
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- permalink /category/post-name with custom post type and taxonomy
- “Post name” permalink returns home page for custom posts
- Custom post type and taxonomy permalinks
- Hierarchical permalinks for custom post type and taxonomy
- How to organize hierarchical structure in custom post type with taxonomy (like with categories)
- Make custom post types and pages place nice, re: rewrite
- Custom Post Fields at the beginning of a Custom Permalink
- Flush Rewrite Rules when new site is created on network
- Pretty URLs and custom post types
- Form action doesn’t work if slug isn’t same as custom post title
- Custom post type archive page for multiple post types
- How to make permalink structure %category%/%postname%/ work for custom post type?
- set permalink for CPT
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Lost of query parameter when using permalink
- Custom permalinks rules don’t match and lost of query var in the process
- Custom Post Type – Duplicate Page Slugs
- Rewrite rule for Custom post type Monthly and Yearly archive
- Different results between permalink and query var search
- menu link to custom post_type?
- Custom permalink with child taxonomy terms
- Custom post type Permalinks with hierarchical Taxonomies
- 404 in custom post type feed with mistake permalink
- Add a permalink variable onto custom post type URL after post name slug
- Remove permalink for custom post type
- Permalink misbehaving in Custom Post Types
- Check post on publish for blank title
- How to solve this custom post type goes to 404 page?
- Best way to specify “article type” in URL
- Template files for Custom Post Type and Taxonomy
- How to Create Template File for Parent Page of Custom Post Type
- How do you create %post_type%/%postname%/ permalink structure?
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- Changed permalink structure of CPT – should I redirect?
- How to query 2 custom post types that need to share a slug?
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- I’m having trouble getting the permalink sample on my custom post type edit page to work
- How to change path for default WordPress blog posts?
- How to hyperlink content from archive page with custom post-type
- Can’t use pagination with custom taxonomy
- retrieve permalinks of posts inside custom post type by using post ID
- Custom Permalinks with meta value not working. Why?
- Custom post type as child of page
- Remove custom permalink structure from custom post type without modifying register_post_type() directly
- How to have permalink like domain.com/term/postname?
- Can variables be used to rewrite a Custom Post Type permalink? [duplicate]
- make permalink go to a custom single.php file
- Custom Post not working as expected
- Custom post type permalink sends to 404.php
- Post will not load via ajax
- Template for custom post type when taxonomy is in the URL
- One Custom post type 404’s others don’t
- Custom Post Type posts, conflict with posts after add_rewrite_rule to top
- How to change base in tag URL for custom post type, to not use “Custom Structure” set in Permalinks setting?
- Combine multiple CPT names to create valid permalinks
- Permalink problems with custom post type and custom taxonomy
- How to implement a different permalink structure for custom post type?
- How to add a sub directory to WordPress single posts without affecting other post types?
- Set parent for custom post type archive rewrite url
- How to rewrite the beginning and end of the permalink structure in a custom post type?
- Route subpage to Custom Post Type
- Custom Post Type “MUST NOT” be able to search via URL
- Custom post type permalink returns 404 when set to private
- Custom Post Type Advanced Slug
- Dynamic CPT permalink structure based on ACF field value
- Custom post type slug 404
- Custom permalink not working and showing 404 page not error
- Custom Post Type permalink without /%day%/ and/or /%postname%/
- How to filter a custom post type by custom taxonomy without 404
- How to get all posts related to particular category name on button click?
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Post type Permalink
- get the permalink never return with empty value
- Custom Post Type to replace Woocommerce products – page not found error
- WordPress custom permalink and archive link for custom post type
- Ideas on how to organize a project [closed]
- Redirect User From Registration Page To CPT (profile page) with custom url
- Custom Post Type Archive template not being called
- Custom Post Type with Configurable Sidebar via ACF
- Custom Post Types,Permalink and Heirarchy
- Pagination of custom post type leads to 404 error
- Easy reading or transfer of data from posts?
- Custom Post Type with modified permalink structure results in 404
- Custom permalink structure for remote content pages
- Custom Post Type Pretty Structure
- Enabling permalinks disables custom page template
- WordPress Custom URLs
- Which is the neatest way to have homepage articles and a blog?
- Setting a homepage – doesn’t seem to work
- CPT, meta-data, url parameter
- Need to return a string as permalink insted of str_replace
- Change permalinks for custom post type based on taxonomy term
- How to setup a permalink structure for a custom post type
- Improve Custom Post Permalink Structure
- Under What Conditions Can I name my CPT the same as my CPT Page?