Rewrite rule to simulate page hierarchy results in 404
Rewrite rule to simulate page hierarchy results in 404
Rewrite rule to simulate page hierarchy results in 404
You can have a different slug for the archive by setting has_archive to a string: register_post_type( ‘whatever’, array( ‘has_archive’ => ‘whatever/results’, ‘rewrite’ => array( ‘slug’ => ‘whatever’, ), // …etc. ) ); I’ve tested that and it seems to do exactly what you needed.
Pretty permalinks and rewrite rules are the same thing, so you need to have them turned on for custom rewrite rules to work.
Turns out i was able to make it work by hooking into parse_request . add_action(‘parse_request’, ‘serve_index_json’, 0); function serve_index_json($wp) { // Exit early if not the right request if (‘my-category-slug/index.json’ !== $wp->request) { return; } $data = array(); $args = [ ‘posts_per_page’ => -1, ‘category_name’ => ‘my-category-slug’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => … Read more
Your regex cannot work: $wp_rewrite->preg_index(3) doesn’t match anything, because you capture only one part in ‘/([0-9]{4})/?$’, not three. Try to add the page parameter: $pagination_base = $GLOBALS[‘wp_rewrite’]->pagination_base; $month_archive = array( $myqueryslug . ‘/([0-9]{4})(‘ . $pagination_base . ‘/(\d+))?/?$’ => ‘index.php?year=” . $wp_rewrite->preg_index(1) . “&post_type=” . $myqueryslug . “&paged=’ . $wp_rewrite->preg_index(3) ); I haven’t tested it, just … Read more
The technical answer to this is to put an .htaccess file inside your wp-admin folder with this code: # Remove .php from pages so you can use /wp-admin/edit RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php # Use /wp-admin/addnewpost RewriteRule addnewpost post-new.php The practical answer is that this is completely horrible, involves … Read more
This isn’t strictly a WP question, but this should work – not necessarily the most efficient representation though: RewriteRule ^(.*mytheme/)pdf.php http://mysite.com/pdf This (http://martinmelin.se/rewrite-rule-tester/) is a very useful site for testing rewrite rules.
Just use the following rewrite argument in your register_taxonomy() call: register_taxonomy( ‘product_cat’, ‘product’, array( ‘rewrite’ => array( ‘with_front’ => false, ‘slug’ => ‘product/poruct-cats’, ), // Other arguments ));
Your external rule doesn’t work because you’re using a format that only works for internal rules- $matches[1] is essentially nonsense in the context of an .htaccess file. Using the $matches array will only work when rules are parsed by PHP, external rules need to use the standard $1 instead of $matches[1]. Any rule that doesn’t … Read more
Filter posts and custom taxonomy using add_rewrite_rule