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 code here.
// And then send the HTTP status and also the Content-Type headers.
status_header( 200 );
header( 'Content-Type: image/jpeg' );
// ... echo your image.
exit;
}
} );
And note that status_header()
is a WordPress function for sending HTTP status header. See the documentation for more details.
Related Posts:
- Custom routes for custom post type?
- Custom post type routing with hierarchy
- Child page in custom post throws 404 page not found
- Multiple templates for a custom post type
- Custom post type as child of page
- How to implement very unusual wordpress routing structure?
- wp_get_nav_menu_items doesn’t return custom post type item
- Add specific route for Custom Post Type (add/edit…)
- Group based routing and administration
- Redirect sub-page URLs to parent without changing URL
- Showing User’s Post Counts by Custom Post Type in the Admin’s User List?
- Confusion with adding meta capabilities to a role after registering a Custom Post Type with corresponding ‘capability_type’ parameter
- Display content from custom meta boxes in revisions
- Custom taxonomy not showing up when adding a new custom post type
- Including Custom Post Types in “Recent Posts” Widget
- WP cron: when to schedule a 1-time event
- Pre get posts for single post
- Custom Posttype Inheritance (and url structure)
- How to get custom metabox image field?
- Custom Post Types – Capability Type
- Custom Post Type pagination – normal solutions aren’t helping
- Custom Post Type Archives by Date (stored as meta value) WP3.1
- Rewrite permalinks for custom posttype and custom taxonomy
- How to check if last uri segment is a custom post type or taxonomy term?
- Pass parameter to custom post type single while keeping clean url
- Pagination Doesn’t Work
- The editor has encountered an unexpected error. // TypeError: Cannot read property ‘prefix’ of null
- How do I write this SQL statement for Posts written in last 24 hours?
- Post Rank on Single Post page based on custom field
- Customized first post techniques
- Storing Custom Post Type Data in a Custom Table
- `post_type` => `any` not giving me my custom post
- Custom Permalink for Taxonimie and Custom Post Type
- I am having a problem with form updating/editing WordPress post on the frontend
- Adding the taxonomy before the custom post type
- Combine query_posts() and get_posts() into single query
- How do I create filters for custom post types?
- Duplicate Custom Header Functionality into the post edit screen
- Returning a list of custom post types excluding those without a specific meta_value
- Customize the Dashboard Menu Editor
- How to allow visitors to enter custom post type?
- Paging doesn’t work?
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- How to render a custom post type template with custom fields using shortcode
- How to handle a CSV with 65,000+ rows and make it searchable?
- I am having Trouble to get list of Categories of Custom post Type
- How to query WordPress posts bycustom field with a max characters’ length
- Limit the post for differents custom post type in the same wp_query
- meta box on custom post type
- Categories filtering in new post
- Pagination custom post type not working with rewrite slug
- Automatically create child custom post when creating a custom post
- How can I have different content for different countries?
- ACF repeater field usage
- Create a comments template for custom post types
- Is it possible to add posts and images (auto resize) for custom post types with a script?
- Retrieving meta-box from a custom-post-type
- Loop through posts of only 2 statuses
- providing access to post_id or post inside functions.php
- Overriding Plugin Function in Child Theme
- Display custom posts for each category from its custom taxonomy
- Function to limit number of custom post types on homepage – TwentyTen
- Get custom category ID of current custom post within the loop
- Post query missing an elseif statement
- How to limit what Editors see in the admin?
- Custom Post Type not working with Capabilities
- Custom Post Type Template Insert not working properply
- Custom Post Type Pagination on Single.php?
- display custom post on separate page
- Add custom post type to query
- How does one go about converting custom post type to post format?
- How to display magic field’s custom write panel in wordpress theme?
- Admin slow on Postlist (over 30k Posts in Database)
- Disable single page for a custom post type based on a custom field
- Show all post type posts in manage users posts column
- Setting Custom Post Type Parents/Hierarchies
- Query to Exclude Child Pages from Custom Post Type Archive
- Modify category permalink to use post type slug
- Getting a Post ID to show its content in a Popup
- search results to show individual ACF fields from inside custom posts
- How to make password protected posts that will expire after they are used?
- Automatically / dynamically populating tags in custom post type
- Remove CPT Slug with 2 taxonomies and 1 post meta
- Single Page of Custom Post Type Not Showing the Content Of post
- Multiple loops for custom post type to spread data across rows
- Generate slug and meta data if meta field is empty
- Why is a custom post type’s URL “/?cposts=name-of-the-post” but default post’s URL is “/?p=ID”?
- Redirect Custom Post Type after user submits update
- Roots: Custom Post Type 404 Not Found [duplicate]
- WP_Query get posts where post_name is empty
- Display all post types together
- Custom Post Type Tags Showing Under Regular Post Tags
- Taxonomy and Rewrite Structure
- Pagination for a Custom Taxonomy
- Nested loop called with shortcode duplicating the content above the main loop
- Pagination for event query
- Problem retrieving custom field for a custom post type
- Remove custom meta boxes from custom post type
- How to make a non-public post on wordpress approval?
- Quering array of post types & pagination. Articles are repeating sometimes on different pages