Adding two rewrite rules

1. Change new_category taxonomy’s rewrite rule while registering: ‘rewrite’ => [‘hierarchical’ => false, ‘with_front’ => false, ‘slug’ => ‘news’] Make sure rewrite rule of news post type is default or: ‘rewrite’ => [‘slug’ => false, ‘with_front’ => false] 2. Add rewrite rules for new_category: add_action(‘init’, function() { add_rewrite_rule(‘^news/([^/]+)/?$’, ‘index.php?new_category=$matches[1]&post_type=news’, ‘top’); }); 3. Filter news post … Read more

Rewrite rule : custom post type with 2 numeric variiables

add_rewrite_rule() cannot automatically create that permalink structure for you. You should use wp_link_pages_link filter. E.g: add_filter(‘wp_link_pages_link’, function($link, $i) { global $post, $photo_id; if ($photo_id && ‘gallery’ === $post->post_type) $link = $link . “https://wordpress.stackexchange.com/” . intval($photo_id) . “https://wordpress.stackexchange.com/”; return $link; }, PHP_INT_MAX, 2); Then, you must use add_rewrite_tag() to make WordPress aware of photo query string: … Read more

Custom Permalink

The custom rule you are trying doesn’t meet the criteria. Here’s a nifty online .htaccess tester tool to see to check rewrite logic. Use the follow RewriteRule instead: RewriteCond %{QUERY_STRING} (^|&)name=(.*) RewriteRule ^(.*)$ /profile/%2/? [R=301,L] Be sure to replace ^example\.com$ on the first line with your actual domain. You can also embed it in the … Read more

Optional all capture groups in rewrite rule

Ok after 4 hours I managed to make it work function pl_add_rewrite_rule() { // this works with pagination too add_rewrite_rule(‘^slike(\/([a-z]+))?(\/([a-z]+))?(\/page\/([0-9]+))?$’,’index.php?page_id=45893&carstvo=$matches[2]&kategorija=$matches[4]&paged=$matches[6]’,’top’); add_rewrite_tag(‘%carstvo%’,'([^/]*)’); add_rewrite_tag(‘%kategorija%’,'([^/]*)’); } add_action(‘init’, ‘pl_add_rewrite_rule’, 10, 0);

Remove custom taxonomy base from URL

Depending on how you are registering your custom post types, you can simply set the rewrite rules for it like so: $args = array( ‘description’ => ‘Photograph Post Type’, ‘label’ => __(‘Photographs’), ‘public’ => true, ‘rewrite’ => array( ‘slug’ => ‘photograph’), ); register_post_type( ‘photograph’ , $args ); If (for some bizarre reason) you don’t have … Read more

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