How to have multiple rewrite endpoints in the same URL?

I also need this to work: example.com/nice-page/my-gallery/animals/cats/my-lightbox/1234 Where I’d like to register my-lightbox as an additional endpoint or query_var, because it could be used independently from without my-gallery, such as: example.com/another-page/my-lightbox/2345 Here’s an example of doing it using add_rewrite_rule(): add_action( ‘init’, function() { // This will let you use get_query_var( ‘my-gallery’ ). add_rewrite_endpoint( ‘my-gallery’, EP_PAGES … Read more

Custom URL routing based on cookie value

SESSION variables aren’t reliable, and won’t work on some WP hosts. Even worse, you’re going to prevent caching But more importantly, don’t route, redirect! Routing and redirecting are not the same thing So, we want the following logic: on the template_redirect action if the user is on the homepage aka is_home call wp_safe_redirect redirect to … Read more

How to get “extended” path info from URL in a plugin

In reply to “Update 1“: The code worked fine for me. So, I’m still getting a 404 when I go to “mypage” with anything following the pagename, like so: http://example.com/mypage/foo. Because your RegEx pattern is ^category/([^/]+)/?, so the URL you should have visited is http://example.com/category/foo. But then, you shouldn’t use category because that “base” is … Read more

Allow single quote in URLs

WordPress will strip off special characters, since they can cause issues when writing to the database. It’s best practice to avoid using special (reserved) characters in URLs, as they can and will break when passing them around. Case in point, see your own post and the cutting off of the URL after the ‘.

Access $_POST data after redirect

Redirects are GET requests usually, and the browser doesn’t send the POST data for those. That’s not something WordPress can change. You could create a session, or – better – process the POST data first, then redirect. In your plugin, you could do: add_action( ‘plugins_loaded’, ‘process_post_data’, 0 ); function process_post_data() { // Read raw POST … Read more

Rewrite WordPress Custom URL

WordPress has its own system managing redirects and page routes, you don’t need to edit the .htaccess file. You’ll want to start with the function add_rewrite_rule(). It takes 3 arguments: route (as regex) query vars priority So first, you need to find out the query vars of account/customer-bookings/. If it is a page, it can … Read more

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