Hot answers tagged rewrite-rules
7
Always flush the rewrite rules when you register a new public post type or taxonomy. Otherwise the internal rewrite rules will not take that into account when an URL is mapped to a query.
You can automate that process by hooking into registered_post_type and registered_taxonomy.
Below is the updated code, based on feedback from comments and other people.
...
2
Redirects are GET requests usually, and the browser doesn’t send the POST data for those. That’s not something WordPress can change.
You could create a session, or – better – process the POST data first, then redirect. In your plugin, you could do:
add_action( 'plugins_loaded', 'process_post_data', 0 );
function process_post_data()
{
// Read raw POST ...
1
one way you could do this with an internal WordPress rewrite, which would then set a query var you could check when enqueueing your javascript, and pass that data via localize script.
so first, rewrite rule to intercept requests to gallery/ with something appended, load the page named gallery, and set the query var gallery_id to whatever was in the URL. ...
1
I faced the same problem and just solved the issue after spending close to an hour figuring out the issue.
So if your CPT (custom post type) single pages are using the index.php and not the single-post_type template, make sure you're not using query_posts improperly. For me, it turned out that I forgot to call wp_reset_query on one of the sidebar pages ...
Only top voted, non community-wiki answers of a minimum length are eligible