Is there a ‘rake routes’ for wordpress?
var_dump( $GLOBALS[‘wp_rewrite’] ); this is as close as you’ll get. Anyway, there’re plugins like the “MonkeyMan Rewrite Analyzer” and toschos T5 Rewrite plugins that will allow you other nice things too.
var_dump( $GLOBALS[‘wp_rewrite’] ); this is as close as you’ll get. Anyway, there’re plugins like the “MonkeyMan Rewrite Analyzer” and toschos T5 Rewrite plugins that will allow you other nice things too.
I’m going to try to put an answer together based on my understanding of the information provided. I’ll outline a couple of assumptions before I start working through the logic: 1) Like Picard you’ll bypass the standard WP template hierarchy in favor of an index.php fall through. 2) The endpoints will be provided by the … Read more
It turns out the WordPress permalink structure works perfectly well for custom types, e.g. example.com/recipes/lunch/sandwich/. This works exactly as expected if you set ‘hierarchical’ => true. What I was originally trying to do was unnecessarily difficult to execute, and requires properly setting up a custom permalink structure to avoid 404 errors. I advise you stick … Read more
When you declare the custom post type, there is a parameter “rewrite” where you declare the slug for the post type. Change the slug to “media/videos”, and then visit your Settings > Permalinks page to update your rewrite rules. register_post_type( ‘videos’, array(‘labels’ => array(), ‘rewrite’ => array( ‘slug’ => ‘media/videos’, ‘with_front’ => false ) ) … Read more
Custom URL rewrite to specific page template
Rather than change .htaccess, move the index.php up to root, open it, and change: require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ ); to: require( dirname( __FILE__ ) . ‘/wp/wp-blog-header.php’ ); In Settings, your WordPress address should be http://example.com/wp, and Site address should be http://example.com. This process is outlined in the Codex page Giving WordPress Its Own … Read more
Jan Fabry wrote a very useful plugin that I think it would be helpful for you to analyze your rewrite rules.
The WordPress Way of doing it is using query_vars so first you add you vars to the array: //add to query vars function add_query_vars($vars) { $new_vars = array(‘custom_method’,’cm_parameter’); $vars = $new_vars + $vars; return $vars; } add_filter(‘query_vars’, ‘add_query_vars’); then you can check in your plugin for the vars: global $wp; if (array_key_exists(‘custom_method’, $wp->query_vars) && isset($wp->query_vars[‘custom_method’])){ … Read more
SESSION variables aren’t reliable, and won’t work on some WP hosts. Even worse, you’re going to prevent caching But more importantly, don’t route, redirect! Routing and redirecting are not the same thing So, we want the following logic: on the template_redirect action if the user is on the homepage aka is_home call wp_safe_redirect redirect to … Read more
How make a multi language routes, with rewrite rules or rewrite endpoints?