Custom URL rewrite with add_rewrite_rule

Updating the rewrite-rules manually as follows worked for me: function gallery_rewriterules( $wp_rewrite ) { $new_rules = array( “hochzeitsfotografen/([^/]+)/([^/]+)/?([0-9] {1,})/?” => “index.php?fotograf=”.$wp_rewrite->preg_index(1).”& gallery=”.$wp_rewrite->preg_index(2).”&img=”.$wp_rewrite->preg_index(3)); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_filter(‘generate_rewrite_rules’,’gallery_rewriterules’);

WordPress Rewrite Rules

First you have to filter query vars and add your query var to the array: add_filter( ‘query_vars’, ‘wpa56345_query_vars’ ); function wpa56345_query_vars( $query_vars ){ $query_vars[] = ‘cat_id’; return $query_vars; } Then your rule which captures any digits after your pagename coupons and passes that as cat_id: add_action( ‘init’, ‘wpa56345_rewrites’ ); function wpa56345_rewrites(){ add_rewrite_rule( ‘coupons/(\d+)/?$’, ‘index.php?pagename=coupons&cat_id=$matches[1]’, ‘top’ … Read more

How to Add Rewrite Ruled Argument Into Permalink Properly

I’m affraid this “nasty” solution would be the most effective than trying to write some cool function that will translate your permalinks into pretty permalinks: $permalink = rtrim( get_permalink( $id ), “https://wordpress.stackexchange.com/” ) . ‘/foo’ . ‘/2’; The rtrim part (removing trailing slash) is just for to be sure there are not going to be … Read more

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