Prepend meta_value to permalink of post

In this case it seems like you’ll want to hook into the WordPress rewrite rules. {$permastruct}_rewrite_rules doesn’t have a lot of information, but this filter would allow you modify the array of existing rewrite rules to add in your new rewrite rule for series. For this to work: http://example.com/series/movie_slug/parrent_series_slug/series_slug You’ll need to add in movie_slug, … Read more

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