Custom permalink structure for custom post types including multiple taxonomy

This code produces the right structure but the post can’t be found (404) That is because the custom rewrite tags (%filter_1% and %filter_2%) appeared as-is in the generated rewrite rules (in the database). So you need to register the tags so that they’re replaced with the proper RegEx (regular expression) pattern when WordPress (re-)generates the … Read more

Category permalinks don’t work even after flushing

The default WP category is only set-up to show posts out of the box. You should be able to expand this by doing something like the below in your functions.php: // Order course archive and taxonomy views function adjust_main_query($query){ if ( ! is_admin() && is_category() && is_category() && $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘post’, … Read more

Rewrite/Change custom taxonomy slug

Try using the below code to overwrite arguments of already registered taxonomies. function wp_modify_taxonomy() { // get the arguments of the already-registered taxonomy $custom_category_args = get_taxonomy( ‘genre’ ); // make changes to the args $custom_category_args->rewrite[‘slug’] = ‘chambers’; $custom_category_args->rewrite[‘with_front’] = false; // re-register the taxonomy register_taxonomy( ‘genre’, ‘chambers’, (array) $custom_category_args ); } add_action( ‘init’, ‘wp_modify_taxonomy’, 11 … Read more

Rewrite only if no other matching page is found

It turns out it was because the default category archive pages do not require the URL to start with /category. WordPress already matches the path /{category-slug} for the default category taxonomy archive. I fixed it by changing the default category archive rewrite to start with /category. function move_category_rule($rules) { if(array_key_exists(‘(.+?)/?$’, $rules)) { $val = $rules[‘(.+?)/?$’]; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)