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

Add custom URLs to WordPress’s XML sitemap

Sitemap Provider It’s possible to create a so called custom sitemap provider and register it with wp_register_sitemap_provider(). It’s helpful to look at the core setup, e.g. for the WP_Sitemaps_Posts provider and also the dev notes. Basic Example – Sitemap with custom URLs Here’s a very basic example that adds the wpse provider that extends WP_Sitemaps_Provider, … Read more

How do I add a php statement to a jQuery string

You might want to try to use wp_localize_script() to allow your javascript to use data that are normally only available using php. Here is the link in the codex that will help you do what you need: https://codex.wordpress.org/Function_Reference/wp_localize_script Another way is to use a php to output your entire javascript code (in a php file, … Read more

Can’t pass table to $wpdb->prepare

The prepare() method escapes %s. The second piece of code you listed breaks because quotation marks are added to the table name, hence it doesn’t match what’s in the DB. The first piece of code works because it’s a straight string replacement hence matching the name of the table in the database. What is the … Read more

Prevent redirect to page/page when reserved term ‘name’ in $_POST when value is a page/post title

I would actually suggest an alternative approach – remove the function that causes the redirect in the first place: function wpse_227033_disable_name_redirect() { if ( is_404() && isset( $_GET[‘name’], $_GET[‘instID’] ) ) remove_action( ‘template_redirect’, ‘redirect_canonical’ ); } add_action( ‘wp’, ‘wpse_227033_disable_name_redirect’ ); I’ve used the wp hook which runs pretty much just before template_redirect. Remember you’ll need … Read more

Pass query string to page

This should actually work for you: function header_resized_img () { $image = wp_get_image_editor($_GET[‘path’]); $height = $_GET[‘height’]; $width = $_GET[‘width’]; if (!is_wp_error($image)) { $image->resize(9999, $height, false); $orig_size = $image->get_size(); $image->crop($orig_size[‘width’]/2-$width/2, $orig_size[‘height’]/2-$height/2, $width, $height); $image->stream( $mime_type=”image/jpeg”); } } and include your function somewhere in the template: header_resized_img(); Then try accessing this URL: http://example.com/image/?width=500&height=400&path=some-url To generate your image.