Custom rewrite rules are sending everything to index.php

Finally figured it out. 1) I was calling the first function at ‘rewrite_rules_array’ instead of ‘init’ which was just dumb. 2) There was still something wrong with it, but I explored another area that seems obvious now, but which I originally glossed over because it seemed to be. https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint https://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/ Just make an endpoint. WordPress … Read more

WordPress URL rewrite regex

From the wordpress documentations – https://codex.wordpress.org/Using_Permalinks Using %category% with multiple categories on a post When you assign multiple categories to a post, only one can show up in the permalink. The categories are ordered alphabetically. In each group of sub-categories the order will also be alphabetical. (see Manage Categories). The post will still be accessible … Read more

When to call `add_rewrite_rule` for safety

The easiest solution to this is to hook your add calls on to the last action which gets fired before the rules are rebuilt during the flush process. The first part of the flushing process is to delete the rewrite_rules option. When this happening the following actions will fire: do_action( ‘delete_option’, $option ); do_action( “delete_option_$option”, … Read more

Clean URLs for custom $_GET variables

You should look at “Rewrite Endpoints”, which are much simpler to work with than custom rewrites. And they fit your use case perfectly: http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint You might add your “show” endpoint like so: function wpsx_37961_add_endpoints() { // Add the “show” rewrite endpoint to all URLs add_rewrite_endpoint(‘show’, EP_ALL); } add_action(‘init’,’wpsx_37961_add_endpoints’); Then you can check for its value … Read more

Sync posts from one WordPress site to another

Have you tried codex.wordpress.org/XML-RPC_Support. This code works, in conjunction with the IXR library found at incutio: include(‘IXR_Library.php’); $usr=”theusername”; $pwd = ‘thepassword’; $xmlrpc=”http://not-therealurl.com/xmlrpc.php”; $client = new IXR_Client($xmlrpc); $client -> debug = true; //optional but useful $params = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘draft’, ‘post_title’ => ‘Test Post’, ‘post_author’ => 4, ‘post_excerpt’ => ‘This is my … Read more

Cyrillic characters in rewrite rules cause 404 Not Found errors

I ended up following @Kolya Korobochkin advice and added uppercase and lowercase versions of the rewrite rules that include escaped octets. $regular_page_uri = get_page_uri( $page->ID ); $uppercase_page_uri = preg_replace_callback( ‘/%[0-9a-zA-Z]{2}/’, create_function( ‘$x’, ‘return strtoupper( $x[0] );’ ), $regular_page_uri ); The Percent Encode Capital Letter plugin uses a similar approach to convert the octets in every … Read more

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