Rewrite rules applied differently after upgrade

I recognize that rule. It’s the unusual rule I wrote to deal with the permalink uncertainty issue. 🙂 First, you’ll only get that weird rule if you have your custom permalinks set to start with a non-numeric value. Like, if you have your custom permalink string as just %postname% instead of something like %year%/%postname%. Next, … Read more

Why isn’t my rewrite rule working when there is no second parameter?

Your regular expression is requiring the last slash be present which it will not be by default. So the path tides/mylocation/ is shortened to tides/mylocation and then tested. Instead, wrap the last part in an optional group using the ? and update the match number. add_rewrite_rule(‘tides/([^/]+)(/([^/]+))?’, ‘index.php?page_id=4348&location=$matches[1]&month=$matches[3]’, ‘top’);

add_rewrite_rule to search

That’s going to the non wp rules because you’re not mapping the URL to the index.php page format. If you want it to be a WP rule, then you need to start the destination with index.php and include the query string to define what you want the query to contain. So if you wanted it … Read more

Add_rewrite_rule doesn’t seem to work?

ok this i didn’t know i had to “register” variable to use function my_add_rewrite_rules() { global $wp,$wp_rewrite; $wp->add_query_var(‘book_id’); add_rewrite_rule(‘^books/([^/]*)/reviews/([0-9]+)/?$’, ‘index.php?page_id=227&bookid_id=$matches[2]’, ‘top’); // Once you get working, remove this next line $wp_rewrite->flush_rules(false); } add_action(‘init’, ‘my_add_rewrite_rules’); and in page-reviews.php i am using $book_id = $GLOBALS[‘wp’]->query_vars[‘book_id’]; One last question: how do i fix my breadcrumbs as the books/…/reviews … Read more

add_rewrite_rule issues

The second one works because post_type=market triggers the market post type archive. Pages have no archive, so post_type=page in the first example doesn’t point to a valid destination. Rewrite rules have to ultimately result in a successful main query. For a specific page, you could use page_id or pagename.

Adding a custom rewrite rule for gallery/categories page

To answer my own question, I didn’t need to remove the ‘redirect_canonical’ filter, and I only needed to change the 2nd parameter for add_rewrite_rule. The resulting function looks as follows: function add_custom_rewrites() { add_rewrite_tag(‘%category%’, ‘(.+)’); add_rewrite_rule(‘^gallery/([^/]*)/?$’, ‘index.php?pagename=gallery&category=$matches[1]’, ‘top’); flush_rewrite_rules(); } add_action(‘init’, ‘add_custom_rewrites’);

How do I turn off the blog and archives?

You are already using pages which does not work the same as posts. You have to remember, pages don’t have taxonomies and they are excluded from the main query by default on all archive pages and the homepage, so there can never be any links to any kind of archive. Archive pages, whether date, category … Read more

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