Where to hook to bypass instantiating WP_Query?

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

WordPress Custom post type single page 404 error

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

Adding custom slugs: parent-page/username/child-page/

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!

add_rewrite_rule doesn’t work for me

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

How to use endpoint, but remove/rewrite endpoint base?

I think the add_rewrite_rule is the correct route to go and I think what you have is correct also barring the Regex. Try substituting what you have currently for this => ^my-page\/([0-9]+)\/?. Full code below: function setup_filter_rewrites(){ add_rewrite_rule(‘^my-page\/([0-9]+)\/?’, ‘index.php?pagename=my-page&my_var=$matches[1]’, ‘top’); } add_action( ‘init’, ‘setup_filter_rewrites’ );