Add Rewrite Rule for custom page

function add_my_rule() { global $wp; $wp->add_query_var(‘args’); $wp->add_query_var(‘arg_username’); add_rewrite_rule(‘writer/([0-9]+)/([^/]*)/page/([0-9]+)’,’index.php?pagename=writer&args=$matches[1]&arg_username=$matches[2]&paged=$matches[3]’,’top’); add_rewrite_rule(‘writer/([0-9]+)/([^/]*)’,’index.php?pagename=writer&args=$matches[1]&arg_username=$matches[2]’,’top’); /*global $wp_rewrite; $wp_rewrite->flush_rules();*/ } add_action(‘init’, ‘add_my_rule’); This should do the trick. One rewriterule for writer/user_id/username (username isn’t used in the rewriterule but is necessarily to make it work. The second rewriterule is the same except that it adds pagination. EDIT: added arg_username in code above.

Rewrite Rules for Multiple (more than 2) Taxonomies

You could try something like this: function custom_rewrite( $wp_rewrite ) { $feed_rules = array( ‘product-category/(.+)/material/(.+)/color/(.+)’ => ‘index.php?product_cat=”. $wp_rewrite->preg_index(1).”&pa_material=”. $wp_rewrite->preg_index(2).”&pa_color=”. $wp_rewrite->preg_index(3) “product-category/(.+)/color/(.+)’ => ‘index.php?product_cat=”. $wp_rewrite->preg_index(1).”&pa_color=”. $wp_rewrite->preg_index(2) “product-category/(.+)/material/(.+)’ => ‘index.php?product_cat=”. $wp_rewrite->preg_index(1).”&pa_material=”. $wp_rewrite->preg_index(2) ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // refresh/flush permalinks in the dashboard if this is changed in any way add_filter( “generate_rewrite_rules’, ‘custom_rewrite’ ); It … Read more

Preventing index.php?category_name=something from redirecting

This should work: add_action( ‘init’, ‘wpa12742_init’ ); function wpa12742_init(){ add_rewrite_rule( ‘category/(.+?)/(\d{4})/?$’, ‘index.php?category_name=$matches[1]&year=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘category/(.+?)/(\d{4})/page/(\d+)/?$’, ‘index.php?category_name=$matches[1]&year=$matches[2]&paged=$matches[3]’, ‘top’ ); } EDIT On second thought, that’s not enough, since you’ll get caught by redirect_canonical(). Add this too: add_filter( ‘term_link’, ‘wpa12743_term_link’, 10, 3 ); function wpa12743_term_link( $link, $term, $taxonomy ){ if(‘category’ != $taxonomy && !preg_match( ‘@^\d{4}$@’, get_query_var(‘year’) … Read more

Old blog/ and blog/feed/ URLs not working after moving blog to top-level via .htaccess

You can skip the first Part of your .htaccess, just use the standard WordPress configuration. The main problem is, you need to create a new index.php in the root directory of your webspace, containing the following: <?php /** * Front to the WordPress application. This file doesn’t do anything, but loads * wp-blog-header.php which does … Read more

How-to add rewrite rules to point the uploads folder to a subdomain

If you are not willing to filter only image uploads, i.e., all uploaded media will reside in the same folder/subdomain, then there’s a simple configuration solution: go to options-media.php set the Store uploads option to wp-content/uploads set the Full URL option to http://uploads.yourdomain.com create a subdomain making the uploads folder be http://uploads.yourdomain.com

How to add a custom URL placeholder to author archives?

Option 1 I assume custom post type generate a URL something like this domain.com/%custom-post-type%/%list% So you could write it so it looks as… since the main URL doesn’t have author before custom type you would have to do this via a function since authors are dynamic RewriteRule ^members/%author%/(.*)$ domain.com/%custom-post-type%/$1 This doesn’t specifically modify the custom … Read more

Regex in add_rewrite_tag not accepting OR operators?

I don’t know what’s wrong but I can suggest: Use Rewrite Rules Inspector or similar to see where your %psubject% rule is and if its pattern ((option1|option2|option3)) has been added correctly. Test http://example.com/somecategory/option1/this-is-the-post-title with the Inspector to see which rule matches. Open http://example.com/somecategory/option1/this-is-the-post-title (when it shows home.php) with the Debug Bar plugin and look at … Read more

Rewrite rule page url with category

Just of the top of my head, something along this way might work: function wpse178647_rewrite() { add_rewrite_rule( ‘^([^/]+)/([^/]+)/?$’, ” ‘index.php?category_name=$matches[1]&pagename=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘wpse178647_rewrite’ ); Completely and utterly untested.

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