My suggestion would be to use a custom page template. In your functions file you require a php file that contains the custom template.
require_once 'buy_page_template.php'
;
and that file declares itself to be a template by containing some commented out text:
<?php
/* Template Name: Buy Page */
Once you’ve uploaded and required that file, a new template appears as a possibility in all your pages in WordPress. You just set the page “buy” to use that template. You can put all the PHP you want into that template, and access the GET variable coming in just like you saw in the other question you cited.
What I do is copy and modify a template file from the theme I’m using.
Related Posts:
- Remove query string specific key value
- Modifying WP URL handing code?
- Best Practice for PHP
- Encode text string being appended as query to URL [closed]
- Is it safe to use $_SERVER[‘REQUEST_URI’]?
- The correct method to pass query vars in AJAX using ajaxurl
- How to check if feed URL was requested?
- urlencoding of the_title() doesn’t work?
- retrieve thumbnail from post ID of best selling product in category
- How to create a WP_Query to search the Title or Tag?
- how to display active, upcoming and past event with featured listing with pagination
- Get list of WP Updates Across Sites
- if statement on database query
- WP_Query meta_query results date by date
- WP_Query sort using multiple numeric meta values
- Help with adding pagination to custom wp_query
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- How to get to a specific position in wp_query?
- WP_Query loop, does not display special characters in title correctly
- How to filter posts by post format “standard” from wp-json api?
- Using foreach loop breaks
- Error when adding excerpt to the content through functions.php
- Loading the same WP_Query in two different wordpress .php templates
- How to prevent WP_Query function from returning all posts when empty?
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to use $_GET function WordPress backend
- How to store post ID’s in cookie or session to display the same posts later
- Extend PHP regex to cover “srcset” and “style” attributes
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Get posts from multiple post type
- Create a Blog Template Page
- Exclude posts with specific metadata from search?
- Display an image if odd number of posts in grid
- Post’s ID pattern?
- Why doesn’t PhotoSmash plugin play well with wp_query?
- the_posts_pagination() not working in wpquery
- How to show meta value code HTML after x paragraph
- Form search query – displaying ACF “Post Object” field as results
- get_the_ID() doesnt work
- change the default order of posts only for specific categories
- Custom post type permalinks do not appear using the link functions
- How do i add slugs to a URL, but still redirecting to the same page
- How can I split my query result in 2 arrays?
- Display an image based on field value
- array_rand not working correctly?
- Nginx WordPress and another Web app URL structure
- WP_Query() load selected post
- How to get post category list as select in front-end?
- Order a WP_Query by meta value where the value is an array
- how to get attached file url for current post?
- How do I check if there is a tag in the title
- How to extract information from a wp_query result?
- Creating customized php files in theme folder
- WordPress Twenty Eleven PhP – forcing php code to skip first post on homepage?
- Using multiple variables to assign categories to an array
- Search.php gets metadata from first post
- the_post(); prints out style text into my HTML?
- search and add in wordpress content
- orderby meta_value_num is not working, giving default order
- How can I modify this code to make the search box include tags and meta
- For some time, some of my pages do not display the content anymore. Any idea where this could be coming from?
- Workaround for og:image unsupported webp image type, Yoast SEO?
- WordPress Search Ajax + Isotope + InfiniteScroll
- How to call my PHP function with AJAX ? wp_query
- Add Link to PHP message
- Query by pagename not Working
- Display featured image of post type category
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Get WordPress username to customize url
- Getting info about selected posts using one WP_Query
- WP_Query To Display Product Of Brand On Taxonomy Page
- How to display last whole post on the homepage
- dynamically change content of div with php
- Need to Echo A Url path to show on a wordpress page
- How to return count of items found in SQL query
- wp_query beginner
- For each 3 posts, show a different post type
- WooCommerce – Print Processing orders [closed]
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- wordpress is_main_query() breaks
- allow previews outside wordpress folder (Outsourcing WP previews)
- Overwriting a Shortcode
- How to get category pages to look like a certain archive page?
- Post Title Not showing up
- Advanced Taxonomy query, with 3 post types
- Passing multiple variables through url (php)
- reorder a WP_Query, using a dropdown
- Custom query_posts() parameter
- Why does a meta_query break this WP_Query?
- How to modify this function to exclude also the post belonging to a specific category?
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Display biography post for today’s birthday person
- How can I change the URL via add_rewrite_rule()
- Variable ++ in query loop
- XML WP_Query problem in PHP 8.0 and 8.1
- a problem in class in class-wp-hook.php
- Count custom posts type and filter by tag
- AJAX WP_Query’s order and orderby parameters not working