how do i create a specific handler for a url?

You could use the parse_request hook. For example: add_action( ‘parse_request’, function ( $wp ) { // Run your actions only if the current request path is exactly ‘image-generator’ // as in https://example.com/image-generator if the site URL is https://example.com if ( ‘image-generator’ === $wp->request ) { $a = $_GET[‘a’]; $b = $_GET[‘b’]; $etc=”etc”; // … your … Read more

wordpress – load a template based on the URI

I assume that your custom post type windows would map onto /windows/ etc? You can customise the template for individual custom post types via single-posttype.php in your theme, e.g. single-windows.php single-doors.php and single-garages.php WordPress will automatically pick these up You could also use custom page templates, e.g. page-windows.php or custom templates with the right template … Read more

WordPress and VueJS routing problem

This is the default WordPress .htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Please add add the following line to it to prevent the default behavior for your custom route. RewriteCond %{REQUEST_URI} !^/my-vue-route/(.+) Like this: … Read more

In wordpress I am manipulation 404 response. I want to give the response before 404 error is given to google

WordPress has a function to send a different status header: status_header( 200 ); If you send that after WordPress has send its headers and before you print anything you will get a status header 200. You could also filter ‘status_header’ and change the value there. See wp-includes/functions.php for details.

REST API: No route was found matching the URL and request method

It’s because of how you’ve defined the accepted methods: ‘methods’ => ‘\WP_REST_Server::CREATABLE ‘, You shouldn’t have quotes around it. WP_REST_Server::CREATABLE is a string that equals ‘POST’, but by putting quotes around it you’re literally setting the method as ‘\WP_REST_Server::CREATABLE’, which is not a valid HTTP method. You can see this in the response to the … Read more

Static raw HTML page

Here is what I have in my own .htaccess file that does what you’re looking for: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymLinks RewriteBase / RewriteRule ^index\.php$ – [L] RewriteRule ^example.html$ /wp-content/raw/example.html [L] RewriteRule ^download$ /wp-content/raw/download-ebook.html [L] RewriteRule ^thanks$ /wp-content/raw/book-opt-in-thank-you.html [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # … Read more

How to display a raw HTML page (bypassing WordPress theme, scripts, etc)

If you’re willing to create a child theme and put your PHP files in there, this approach is relatively clean. For each file, create a rewrite rule where you specify the path you want to use and the filename that should load. In the example below, /custom-path/ loads custom-file.php from the root of your child … Read more

How does routing on wordpress work?

In WordPress, URLs don’t map to routes. They map to database queries. When using WordPress in the “default” permalinks mode, you have a set of variables in the main URL query, like ?p=1 or ?page=234 and so forth. There’s also ?s=search and many others. If you use the “pretty” permalinks, then a big set of … Read more