I have some text blocks which are used various times.
I want to be able to add them as txt files to a folder in my theme, and then add one to specific posts and pages with either a shortcode or include.
I’ve found various plugins which don’t work (deliver ‘failed to open, no such file’) errors. And functions which can create shortcodes, but which can’t handle multiple shortcodes in a single function.
get_template_part to insert regularly used files throughout your site.
Example of use:
get_template_part( 'PATH/FILE_NAME' );
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