Rewrite for page with a possible unknown parent page

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

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

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