WordPress .htaccess blocks mine?

Try resetting the default error document at the start of your .htaccess file: ErrorDocument 410 default If you have a custom 410 error document defined elsewhere in your server config then this could end up being routed by WordPress. (I’ve encountered some shared hosts that (for some reason) define a custom “default” ErrorDocument in the … Read more

force category base – archive pages work WITH & WITHOUT category base slug in url?

I found a solution here: 404 on category.php pagination So, to fix my issue I just needed to add these custom rewrite rules to functions.php: add_action( ‘init’, ‘wpa58471_category_base’ ); function wpa58471_category_base() { add_rewrite_rule( ‘blog/([^/]+)/page/(\d+)/?$’, ‘index.php?category_name=$matches[1]&paged=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘blog/([^/]+)/(feed|rdf|rss|rss2|atom)/?$’, ‘index.php?category_name=$matches[1]&feed=$matches[2]’, ‘top’ ); } Now, all blog pages work, including main blog page, archives, categories, and … Read more

How Can I Change a Taxonomy URL Based On The Originating URL?

The term_link filter has a different signature for its callback function than the page_link filter, meaning the arguments in your callback are different. (Also note you’ll need to explicitly set the argument number when you call add_filter because by default add_filter will only setup 1 argument. For example: add_filter( ‘term_link’, ‘lqd_series_link’, 10, 3 ); // … Read more

Url Rewriting a dynamic wordpress page

thanks for you reply, So after much digging, it’s working : function myplugin_rewrite_tag_rule() { add_rewrite_tag( ‘%symbol%’, ‘([a-zA-Z0-9_]+)’ ); add_rewrite_rule( ‘^crypto-monnaies/([a-zA-Z0-9_]+)/?$’, ‘index.php? pagename=showcoin&symbol=$matches[1]’,’top’ ); } add_action(‘init’, ‘myplugin_rewrite_tag_rule’); function add_query_vars( $query_vars ) { $query_vars[] = ‘symbol’; return $query_vars; } add_filter( ‘query_vars’, ‘add_query_vars’ ); Please note that if you dynamic page is a second level page, you have … Read more

Relative URLs for a particular custom post type?

At @milo’s suggestion, I used the post_type_link example and adapted it to my needs. This made it so only my chosen post type would be relative, while leaving any other custom post types functioning as usual. function make_yourposttype_relative ( $url, $post ) { if ( ‘yourposttype’ == get_post_type( $post ) ) { add_filter( ‘post_type_link’, ‘wp_make_link_relative’ … Read more

How to use URL structure to call PHP code

I assume alan-walker is just an example and this could be any string of this form. (Or is it literally just “alan-walker”, as in you example?) You can do this with a single RewriteRule in .htaccess before the WordPress front-controller. For example: RewriteRule ^directory/([a-z-]+)$ /directory.php?s=$1 [L] This will rewrite /directory/<something> to /directory.php?s=<something>, where <something> consists … Read more

WordPress custom post type permalink: website.com/post-name/post-id

product/([0-9]+)?$ translates to product/ followed by any number or nothing (and nothing more, not even a trailing slash). This doesn’t sound like the thing you want to achieve. Instead, try the following function wpse33551_rewrites_init(){ add_rewrite_rule( ‘^([^/]+)/([0-9]+)/?$’, ‘index.php?post_type=artikelen&p=$matches[2]’, ‘top’ ); } which translates to: ^ start of the string (ie, there is nothing else in front) … Read more