Rewrite the WordPress URL from custom plugin
plugin_dir_url( __FILE__ ) will return the URL of the current files directory. Usage would be: $url = plugin_dir_url( __FILE__ ) . ‘/newfolder/newfolder/index.php’;
plugin_dir_url( __FILE__ ) will return the URL of the current files directory. Usage would be: $url = plugin_dir_url( __FILE__ ) . ‘/newfolder/newfolder/index.php’;
You can use the pattern (([^/]*)/)? to match a full <component>/ construction – this will create a multi-dimensional element in the $matches array, with the first level containing the full expression and the internal matches containing an item with <component> without the “https://wordpress.stackexchange.com/” character. However, you need to be very careful in the way you … Read more
While it’s possible to get rid of WP_Query in WP load process it’s pretty horribly inconvenient to accomplish. 🙂 Let’s recap the process as related to rewrite: Web server takes pretty permalink and rewrites it to WP’s index.php. WP takes “pretty” part and applies its rewrite rules to it, turning it into query variables. Query … Read more
Rewriting base name Taxonomy same Post Type
It sounds like you misunderstand how to add rewrite rules as your structure is relatively common and should not require flushing the rules on every page load. The impact depends on your set of rewrite rules, and the codex is somewhat outdated and I don’t think it is as bad as it used to be … Read more
I found same problem and I solved with extraordinary article of Brent Shepherd : Advanced Taxonomy Queries with Pretty URLs. This article contains a generic function to solved the problem and instructions for changes permalinks. It’s very important don’t forget enable module php: mod_rewrite in your server and modify the archive /etc/apache2/sites-available/000-default.conf with rules: (for … Read more
Changing default slug of post to the post id
If anyone is wondering I figured it out. Since I was hosting my WordPress site on a Chassis server, the path I needed to use in my require statement was different than the actual path on my machine.
Found the solution! I was trying to over complicate things. The best method I’ve come up with is: $users=get_page_by_title(‘users’); $about=get_page_by_title(‘about’); add_rewrite_rule(‘^users/([^/]*)$’,’index.php?page_id=’.$users->ID.’&username=$matches[1]’,’top’); add_rewrite_rule(‘^users/([^/]*)/about/?’,’index.php?page_id=’.$about->ID.’&username=$matches[1]’,’top’); Haven’t come up with errors yet, haven’t tested yet!
You’ve got it the wrong way round – WordPress won’t rewrite (redirect) your query string (known as canonicalization), but it will pass your parameters through if you use the rewritten URL: http://example.com/test/information/people Now if you print_r( $wp-query_vars ) in your template, you should get something like: Array ( [pagename] => test [information] => people ) … Read more