Use get_template_part
to insert regularly used files throughout your site.
Example of use:
get_template_part( 'PATH/FILE_NAME' );
Where PATH
is the location of the file you want to include, usually a folder within your theme/child-theme example(my-template-folder) NOTE! without leading slash.
FILE_NAME
is the name of your file, WITHOUT extension, example (my-regular-code.php becomes my-regular-code).
So the above would be get_template_part( 'my-template-folder/my-regular-code' );
and this would be placed within the main code of your page, where you want to display it.
As you point out you can also use SHORTCODES, there are plenty of code examples both here and google showing the correct way to make and insert
Related Posts:
- Serving precompressed content with Brotli on Apache
- How can I avoid code duplication for a blog with lots of source code?
- How to rename wp-includes folder?
- What’s the correct way to include files in WordPress TwentyTen theme with it’s own jquery scripts and css?
- ABSPATH not working! Any idea why?
- Get current user data from external PHP page
- External system integration with wordpress
- Why does get_template_part() break variables?
- How to pass variables with get_template_part?
- Problems Including File
- How to include core files into plugin
- How to check if txt file exists inside template folder?
- What’s the best way to ‘include’ a file in WordPress?
- locate_template function – File not getting included
- Can not include file from plugin into theme
- Include tags from array, ignore the rest in get_the_tags
- PHP files included within functions.php don’t work from admin area
- Wp Enviroment problem with included file
- Having trouble linking to file using relative path
- Including php file in directory above WordPress installation
- add_feed failed to open stream
- Load content From Include File within plugin
- including Zend Gdata library path error
- What about “inc” (include) files and Child Theming? Is it possible?
- Make changes in /includes/http.php update safe
- Need to override file included in parent theme
- Class works in Admin, not found on Front End
- if statement parent page for child pages
- add_action outside a plugin
- Add page as static html into another page
- Dynamically determine URI to scripts and styles included with a class which could be added from plugin/theme/child theme/mu plugin
- Include another HTML file in a HTML file
- C++ #include guards
- How do I run a file on localhost?
- Already defined in .obj – no double inclusions
- How do you #include files in java?
- “Multiple definition”, “first defined here” errors
- Difference between require, include, require_once and include_once?
- cmath vs math.h (And similar c-prefixed vs .h extension headers)
- How to add a default include path for GCC in Linux?
- Eclipse CDT: Symbol ‘cout’ could not be resolved
- how to get wp-content folder in wordpress?
- Is there any way to use get_template_part() with folders?
- Order by & include array by specific post ids
- Include PHP file in Content using [shortcode]
- load/require specific php files for specific pages/templates/post types
- bloginfo(‘stylesheet_directory’) vs. get_stylesheet_directory_uri() and include(‘file.php’) vs. get_template_part()
- Sort users in get_users() in custom order
- passing argument to get_template_part() or a better way to code
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- Add few specific post ids to wp_query
- Include Class File in WordPress
- Change title and meta description in included page (not template)
- Include file from higher level
- Include a specific page in your template
- PHP files included in functions.php don’t seem to work
- Include files in child themes, declare in functions.php
- Hardening wordpress: blocking /includes with htaccess
- Include content from one page to another
- Include multiple custom post types [closed]
- PHP help get_template_directory + PHP include
- If a page does not exist, include a different page?
- Override file inside inc in child theme
- Impossible to call wordpress function inside an include?
- Is it possible to include an HTML flat-file website inside a WordPress theme?
- Conditionally include files in functions.php?
- Post’s ID pattern?
- Using WP functions such as the_title() in an included php file
- include specific Pages to wp_list_pages with filter
- How to include custom PHP file both in header and footer files
- How to get the form code from the edit page of a specific post?
- Include a file that has a function in it
- Trying to include files in plugin isn’t working
- Is it ok to chop index.php and include files?
- file.php not loaded?
- Custom metabox not working
- How and when to include shortcode source files
- Displaying page content from plugin, inside exising empty WP page
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Adding a second loop breaks everything
- “Cannot modify header information – headers already sent by” while using get_stylesheet_directory_uri()
- How can I include custom Gutenberg Blocks in a theme?
- Before & After Content – After Content directly below Before Content when using require_once
- Including content into an add_shortcode() function
- loading a php file to a specific page id
- PHP get_category() function redeclared
- Push Shortcode parameter to template
- Using require_once for parent-directory not working but is working in sub-directories
- template_redirect and title
- Include inside sidebar
- Pages included in another page and duplicate content issues for SEO
- How can I include a file related to blog URL? Nothing seems to work
- WordPress blog set up
- Want to include ad code after related post
- Including a PHP file via a function that is part of a plugin?
- After Migration, Warning: include_once() errors on all pages
- Shortcode to include PHP file, pass various parameters to include?
- php include returns 1 as output with other outputs [closed]
- How to include Elementor CSS in custom php file [closed]
- How to include a php file in 404.php file?