Must be something with your setup. Following works for me (inside child theme – should work for any theme though):
single.php:
global $post;
$bla = $post->post_title;
error_log('post title is: ' . $bla);
include('included.php');
included.php:
error_log('i am included file: ' . $bla);
Output in debug.log:
post title is: Hello test
i am included file: Hello test
Both files are inside the same directory.
Related Posts:
- Why (and how?) is get_header() erasing all my stuff?
- Cleaner way to define multiple variables for is_page_template()
- Three step order form, how to go to next step
- How do I update the SEO information on dynamic pages being generated from template_include?
- Is there any way to use get_template_part() with folders?
- is_page_template not working
- When is get_template_part() preferable to simply using the template.php files?
- How to remove all styles for certain page template?
- load/require specific php files for specific pages/templates/post types
- Store Page Template Files in a Subfolder
- Accessing $post variable from template part
- Video Background – (php & css) – generating 404 error on page load – WordPress Theme File Structure Help
- Removing or Restricting Access to Page Templates for Editor Role
- Created custom post type but selected template not staying selected
- Why is POST’ing to my WP page template producing a 404?
- Are page/post IDs unique across a whole network?
- Grabbing the page template name?
- Adding the Admin Bar to a page with a custom template
- wp_title() handling of author page
- Can you call a template file without assigning template to a page in the admin panel?
- How to edit 404 content via wp editor?
- Take Variables Set in Functions.php and Echo Them Inside My Custom Post Template
- wp_redirect() does not work in custom template file
- Programatically changing template of a page
- How to check if txt file exists inside template folder?
- locate_template function – File not getting included
- Creating a new page template
- Unexpected results with conditionals inside template part
- Excerpts for Pages
- Visual Editor Templates
- Pre get posts where template is not equal to one specified?
- Change content of page in child theme using plugin
- Can two custom templates be used to create a single page?
- Use the_title_attribute() for the WHERE parameter in a page template
- Find the page template of the previous page
- How to check if a specific page uses a page template?
- Conditional get template part
- Cant remove line that appears above page content
- Trying to return list of child pages for a template
- Page template without header & footer
- Page template for blog not working
- I want to duplicate homepage for all my pages
- WordPress showing 404 page template for unpublished posts
- Change Post Template based on post meta?
- How to rewrite title- and meta-description templates for page templates in Yoast Plugin [closed]
- Adding a Menu Page to The Dashboard
- !is_page_template not working with && operator
- Is there a way to create a template that does not have the site styling associated with it?
- page shows 404 on form submit
- Is it okay to use page template as contact page? [closed]
- Including facebook.php in a wordpress page template?
- is_front_page and is_home are not working in page.php
- changing background color depending on parent page
- How to build a PDF repository in WordPress
- Page with posts from category doesn’t work
- Why is a renamed custom template file still showing up in the template dropdown menu?
- Page template added via plugin not saved in Gutenberg
- Display ACF if parent page has specific template
- How can I load 2 random pages?
- Creating page & post templates without template file
- Blog page wont use blog-template.php
- Delete post: 2 wp_redirect if pages are different
- The best way to create pages like an ‘about’, ‘contact’ and etc [closed]
- Image not showing on page template in Twenty Fifteen-theme
- Function to load correct CSS for Template not working
- Change page template programmatically inside foreach
- Limit page template choice by page title or ID?
- Using custom url parameters in a page
- WordPress custom login and register page problem?
- Controlling the Admin panel for page templates
- Page Templates automatically showing index page contents?
- Find php file anywhere in folder and subfolder from template
- different sidebars depending on template (is_page_template is not working)
- Create Page with Pagetemplate and get a post_type_object->template
- How to add variables to a template
- Inserting article:tags meta in html head-element, using get tags, no wp_head
- wp_logout() not working after form submission
- Set page title in WordPress with PHP
- How to allow user to select page template from front end?
- send page ID’s to another template
- Converted HTML5 to WP, How to apply converted classes to new pages (after conversion completed)
- Is there a universal slug for static homepage?
- Passing variable from template file to the plugin file
- Target pages using Woo Commerce single product page template
- Using a page-template to restrict access based on IP (Frontend)
- Need help in creating splash intro page using custom page template
- Create a variable with string, array or multiple values
- Using require_once for parent-directory not working but is working in sub-directories
- Adding secondary featured image for page_for_posts
- What is the best way to create very custom campaign pages?
- WordPress fetches the archive page instead of my custom template
- Custom Forget Password page
- Using page template as Static Front Page
- How to make page template with admin able to select NextGen Galleries to be part of the layout?
- Showing sidebar-2 on custom template page
- Background of default template showing instead of the background of custom page template
- Page (template) with only news of the type “gallery”
- Getting a custom area in a theme for dynamic content for page
- Videopress Short Tags not working when pulling page into template
- Article Template