load_template()
is for cases where you need the following global variables in an included file:
$posts,
$post,
$wp_did_header,
$wp_query,
$wp_rewrite,
$wpdb,
$wp_version,
$wp,
$id,
$comment,
$user_ID
If you don’t need those, or if you use global
in those files anyway, it isn’t needed.
locate_template()
and get_template_part()
are for cases when you want to allow child themes to replace the files with their own version. If you offer other ways to turn the loading off, it isn’t needed.
So, it depends on the context, on the position of your theme in the hierarchy (parent or child), and on the included code. You can use require
if you want to. Avoid require_once
and include_once
, they are more expensive.
And shortcodes are not part of a good theme. 🙂
Related Posts:
- Get the blog page URL set in Options
- The proper way to include/require PHP files in WordPress
- Using classes instead of global functions in functions.php
- What is the difference between wp_register_sidebar_widget and register_widget?
- Should we use get_template_part() in functions files instead of include_once?
- Change admin bar to default:off
- Create “File-less” Page Template in Functions.php
- What is the right way to include a wp-admin file in your theme?
- When to use esc_url, esc_html, esc_attr, and friends?
- How to edit bbPress template files – WordPress + BuddyPress + bbPress? [closed]
- How to change post thumbnail title and alt attributes to post title?
- Why might $input (Settings API) be coming through empty?
- Override default cropping in WordPress [duplicate]
- Get password when user registers and save it sha1 into database
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Removing the default sidebar from admin panel
- Merging PHP download script into `functions.php`
- Is there an error in get_the_tag_list()?
- Returning Variables back into a template
- Allow users to add custom functions to wordpress theme
- Change date number to another language/script?
- How to add custom template tag in wordpress theme?
- Nesting Functions within Functions
- Is using eval() ok in this scenario
- Custom php page in WordPress theme?
- Can’t access WordPress functions in file called via Ajax?
- How can I customize wp_footer, where is the code that controls what this function does?
- How to list all images in uploads directory except those that are attached to any post
- Can I change a variable in a content part while calling it?
- More than one meta field in a single meta box?
- Is there a theme function for is_password_protected()?
- how do you create an admin interface in plugin for your theme
- How to determine which custom header image is being shown
- Toggle Sidebar Display
- How to store functions in… functions.php?
- Unhook jQuery from WooCommerce via `functions.php`? [closed]
- trying to use wp_handle_upload with ajax
- Check if home.php and set home.php as page_on_front
- Should I use add_filter for functions in function.php of the theme?
- after renaming my wp-content folder, how do I upgrade my wordpress version?
- Pass variable to hook. Its possible?
- Theme Customizer not loading JS for live preview
- Remove “You are using WordPress 3.2.1” from Right Now Dashboard Widget
- Replace function in a child theme
- Custom theme, contact form 7 & fast secure form doesn’t work
- Is it possible to include an HTML flat-file website inside a WordPress theme?
- Change the “Default Avatar” admin option via functions.php
- Replace single_template filter with what for default posts?
- JQuery undefined and Stylesheet loads in bottom along with js files
- How to call the_time current?
- Add content after get_header
- Can’t change theme name
- How to set default values for edit_post_link() in my theme?
- How to make excerpt image be full size instead of thumbnail?
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- How can I include custom Gutenberg Blocks in a theme?
- Using require_once for parent-directory not working but is working in sub-directories
- Incorrect search results in search.php – issue triggered by using `define(‘BodyID’, ‘search’); the_post();` in search.php
- enqueue script if page is not equal to
- apply_filters to featured image
- Mamp pro permalink issues. Pages keep reverting to index.php
- Want to include ad code after related post
- loading custom.js file after jquery is loaded
- Creating custom function in wordpress to return data from database
- Getting URL of Resized Image
- Adding a new layout for genesis
- themeforce (happytables framework) implementation
- WordPress Includes mejs 404 error
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Between functions.php (theme), widgets, and plugins, which is loaded first?
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- get_template_directory_uri pointing to parent theme not child theme
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- Worthwhile to restrict direct access of theme files?
- How Do I Protect My Premium WordPress App Theme from Copying?
- How to detect mobile devices and present them a specific theme?
- Using wp_add_inline_style without a stylesheet
- How to add posts to custom menus?
- WordPress Theme Preview Image
- How To extend WP_Customize_Control
- What is the difference between front-page.php and home.php? [duplicate]
- How can I get page slug
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- When to use _e and __ for the translation?
- What is a Theme textdomain?
- How to show a custom meta box on the “Quick Edit” screen?
- How to add CSS class to custom logo?
- How to add custom css file in theme?
- How important is it to enqueue a theme’s stylesheet?
- CSS not updating in browser when I change it
- Display Search Result Count
- wp_nav_menu(), how to change class?
- theme path in javascript file