Fixing the 'Posts: invalid template name' Error in Shortcodes Ultimate
Content
If you've recently updated the Shortcodes Ultimate plugin and suddenly see a "Posts: invalid template name" error where your post lists used to be, you're not alone. This is a common issue that emerged after a significant plugin update. This guide will explain why it happens and walk you through the most effective solutions to get your site back to normal.
Why This Error Occurs
Based on community reports, this error typically appears after updating to plugin version 4.9 or later. The 'WP Shortcodes Plugin — Shortcodes Ultimate' team made a crucial security improvement that changed how the [su_posts] shortcode handles template files.
Previously, the shortcode could load template files from almost anywhere, including paths like ../../default-loop.php that pointed to directories outside the active theme. To enhance security and prevent potential exploits, the plugin now restricts template loading to files located within the active theme's directory or the plugin's own template folder. If your shortcode points to a template outside of these allowed paths, it will throw the "invalid template name" error.
Additionally, some users reported that the plugin update process itself sometimes deleted the default /templates/ folder within the plugin directory, which could also cause this error if a shortcode was relying on a default template.
How to Fix the "Posts: invalid template name" Error
Here are the most common and effective solutions, starting with the simplest.
Solution 1: Use a Built-in Template (Quickest Fix)
The fastest way to resolve the error is to remove the custom template attribute from your shortcode. This forces the shortcode to use one of its built-in, secure templates.
For example, change this:
[su_posts template="../../default-loop.php" posts_per_page="10" tax_term="193"]
To this:
[su_posts posts_per_page="10" tax_term="193"]
The plugin will automatically use a default template, and the error should disappear immediately.
Solution 2: Move Your Custom Template to Your Theme Folder
If you require a custom layout and must use your own template file, you need to move it to a safe location. The correct practice is to place your custom template file within your active theme's directory.
- Access your website's files via FTP or your hosting provider's file manager.
- Locate your custom template file (e.g.,
default-loop.php). - Move it into your active theme's folder. For example:
/wp-content/themes/your-theme-name/. - Update your shortcode to point to the new, secure path. The path is relative to your theme folder. You can often just use the filename if it's in the root of the theme.
Updated shortcode example:
[su_posts template="default-loop.php" posts_per_page="10" tax_term="193"]
Important Warning: Never edit or place custom templates directly inside the /shortcodes-ultimate/ plugin folder. Any changes you make there will be completely erased the next time you update the plugin, causing the error to return.
Solution 3: Restore Missing Default Templates
If your shortcode was using a default plugin template (like templates/list.php) and the error appeared after an update, the template folder might have been accidentally deleted. In this case, the simplest fix is to reinstall the plugin.
- In your WordPress admin dashboard, navigate to Plugins → Installed Plugins.
- Deactivate and then delete the Shortcodes Ultimate plugin. Don't worry, this will not delete your shortcodes from your posts and pages.
- Install and activate the plugin again from the WordPress plugin repository.
This process will refresh all plugin files and restore the missing /templates/ directory.
Conclusion
The "Posts: invalid template name" error is almost always a result of improved security measures. By ensuring your template files are in the correct location—either by using a default template or moving your custom file to your theme folder—you can resolve the error and keep your site secure. If you continue to experience issues, the WordPress support forums for the plugin are a good place to search for further community-driven solutions.
Related Support Threads Support
-
Topic posted in errorhttps://wordpress.org/support/topic/whole-page-shifts-left-when-spoiler-opened/
-
Posts: invalid template name – since version 4.9https://wordpress.org/support/topic/posts-invalid-template-name-since-version-4-9/
-
Assistance with some shortcode’shttps://wordpress.org/support/topic/assistance-with-some-shortcodes/
-
Error in shortcode postshttps://wordpress.org/support/topic/error-in-shortcode-posts/
-
Latest Post not showing the literal latest posthttps://wordpress.org/support/topic/latest-post-not-showing-the-literal-latest-post/
-
Posts: invalid template name after updatehttps://wordpress.org/support/topic/posts-invalid-template-name-after-update/
-
Getting the current tag in templatehttps://wordpress.org/support/topic/getting-the-current-tag-in-template/
-
[NSFW] Posts: invalid template namehttps://wordpress.org/support/topic/posts-invalid-template-name/
-
Choosing tags, categories, posts, pages doesnot workhttps://wordpress.org/support/topic/choosing-tags-categories-posts-pages-doesnot-work/
-
Posts shortcodehttps://wordpress.org/support/topic/posts-shortcode-4/