There are two things to do to make this work. First, you have to turn your php file into a template that can be recognized by WordPress. This is simply done by adding the following to the top of your file:
<?php /* Template Name: WPSE Example Template */ ?>
The second thing is, you must make sure this file is not called directly, but through WordPress, so functions like get_header
are recognized. This you do by making a page in WP. You can leave everything blank, including the title. Just make sure that you assign your template as the one to be used by this page. Use the permalink generated when you save the page to display it.
Related Posts:
- Can’t load WP function into external function
- Populate editor with some content of a page with a page template
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- Use .php file as page instead of wordpress page & template file?
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Function to return true if current page has child pages
- Proper use of Output Buffer
- List of all theme customizer control types?
- Need help setting default setting value for radio button in theme customizer
- Multiple is_page() in page.php
- function_exists call in function.php
- Check if a menu is empty?
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Debugging an error: wp_enqueue_style was called incorrectly
- How to get the registered sidebar’s name by its id?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Dynamically change feature image in customiser
- One button to change all settings in theme customizer?
- class=”parent” for wp_list_pages?
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Design view breaking on Pages
- Adjust the results quantity for Search Results page pagination
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- Listing all sub-pages?
- Understanding WordPress child theme custom JS loading
- How can I loop into two different DIVS without repeating the DIVs
- Removing unnecessary wordpress files
- Remove css styles from specific page
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Is it possible to use the featured image of a page as a css background without inlining?
- How do I list the_tags() into HTML data-attribute
- Switching between custom templates in a post type of the admin menu
- Use template for posts with a particular category grandparent
- Can I change a variable in a content part while calling it?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- What is the fastest way to load PHP functions that are only used in one theme template?
- My Own layout in WooCommerce pages [closed]
- Differences when using the the_time and the_date functions
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- syntax issue on php 7.4
- How do I publish only one page to production after making changes on staging?
- Custom Template 404 for specific custom post type
- Custom category code not showing all posts
- Set WordPress Default Template
- Trigger popup in a php if/else statement
- Can’t get page content in WordPress
- Way to querry data (tags) from a wordpress database?
- How can I load a PHP page without using a Template?
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Converting HTML Template to WordPress Theme
- How to remove the cufon script from Dzonia Lite theme [closed]
- How do I add custom bulk actions to multiple custom post types?
- what is the best practice to add new field to an api route
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- Error in custom php function doesn’t exist
- Catchable fatal error: Object of class stdClass could not be converted to string after WP 4.7
- Create Page To Count Comments For Each Post In WordPress Site
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Skt full width basic slideshow problem
- How to disable controls in theme customizer?
- How do I link a button I created in theme customizer to a function?
- Trying to retrieve post meta
- Is there a way to conditionally check whether a WordPress post title is empty?
- Inject class in body when particular page template is used
- WordPress admin-ajax.php
- Adding wrapper elements in the_date() like in the_title()?
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP theme?
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Show About and Contact Us page when they’re clicked in the top menu.
- How to use theme function in post/page?
- get_template_directory adding FTP root folders in urls
- Theme not calling Jquery properly
- Menu to the right of screen on desktop using Bootstrap 4
- Getting page / post URL on publish and / or update
- How to include a function in a template with template tag
- What syntax is this? “{{post.price}}”
- Theme editing “post thumbnail” help
- Where can I find the declaration of `$_wp_theme_features`?
- Calling PHP function doesn’t work in index.php
- Create a custom theme-specific page, invisible in the admin-panel?
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Save the outputted image into the Media Library, with a different filename and extension
- WordPress get_post_meta issue
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- How to add button to top of theme customizer?
- Adding code to the function file
- I need a button to appear when not loged in and another when logged in, I need help fixing code PLEASE!
- Load slideshow.css file only if Slideshow is checked / on
- Loop on a wordpress Page instead of content coming from the WP text editor
- Twig+WordPress how to use array arguments inside a function?
- How can I fix my pagination?
- require used as a function to load theme dependencies?
- WordPress post-template null warnings
- Custom theme on multisite has issues with standard loop output