Remove the Parent category from the permalink but leave the child category

I think, there are two things to be resolved: 1) You need that posts (and other post types) also followed that command, so use both: add_filter( ‘post_link’, ‘remove_parent_category’, 10, 3 ); add_filter( ‘post_type_link’, ‘remove_parent_category’, 10, 3 ); 2) but then categories also need to have changed url, so use: add_filter( ‘category_link’, ‘remove_parent_category_2’, 10, 2); function … Read more

Custom rewrite rule serves content, but returns 404 error code

This has been an issue in core for a while, http://core.trac.wordpress.org/ticket/10722. The simplest solution is to just overwrite the headers on ‘template_redirect’. You can replace them as long as you haven’t started any output yet, which you shouldn’t have at this point. Just call status_header( 200 ); No cache headers are also sent when the … Read more

Adding more pages to author pages

The author rewrite rules are filtered through author_rewrite_rules. You can add a rule there for the pattern author/([^/]+)/edit/?$, but the substitution will depend on how you want to create the edit page. A simple example that will set a custom query variable and load a specific template if this variable is set: add_action( ‘author_rewrite_rules’, ‘wpse18547_author_rewrite_rules’ … Read more

Issue with using .htaccess to redirect feedburner feed

Try this. This format works for me. You don’t have to keep repeating IfModule, RewriteEngine, RewriteBase. # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC] RewriteRule ^feed/?.*$ http://feeds.feedburner.com/mysite [L,NC,R=302] RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] RewriteRule ^download/([^/]+)$ http://www.mysite.com/blog/wp-content/plugins/download-monitor/download.php?id=$1 [L] </IfModule> # END WordPress … Read more

custom url rewrite

Your rewriterule should be: add_rewrite_rule(‘^directory/view/(.+)/(\d+)/’, ‘index.php?pagename=directory/view&search=$matches[1]&number=$matches[2]’, ‘top’); Remember to flush your rewriterules after every edit (go to settings > permalinks). EDIT added complete code example. function add_directory_rewrite() { add_rewrite_tag(“%search%”, ‘(.+)’); add_rewrite_tag(“%number%”, ‘(\d+)’); add_rewrite_rule(‘^directory/view/(.+)/(\d+)’, ‘index.php?pagename=directory/view&search=$matches[1]&number=$matches[2]’, ‘top’); } add_action( ‘init’, ‘add_directory_rewrite’ ); In page.php for testing purposes: <?php echo get_query_var(“search”); echo get_query_var(“number”); ?> This worked on my … Read more

Author Profile URL

To change all author URLs one would normally change the author base, however, since you want multiple author bases, we’ll have to do things a bit differently. There are two parts to this – The first part is getting WordPress to recognize incoming requests for your custom author pages and route them properly. To do … Read more

External/non-WP rewrite rule without QSA

The apache rewrite flags like QSA are hard coded, see source. Not sure why it would bother you, but if you really want to change it, then you can and should use the mod_rewrite_rules hook for that. Below an example on how to do it: add_filter( ‘mod_rewrite_rules’, ‘wpse107528_change_mod_rewrite_rules’ ); function wpse107528_change_mod_rewrite_rules( $rules ) { $pattern … Read more

Multiple Permalinks for Same Post

The request parsing is handled in WP::parse_request(). After that, there’s a action hook parse_request which gives you the instance of the wp object. We assume that http://www.example.com/my-custom-post-type/this-is-a-cool-article is your permalink and http://www.example.com/mon-type-de-poste-personnalise/cest-un-article-sympa ends up in a 404. So the first thing to check in your callback should be, if the wp object is in a … Read more