Join Stack Overflow to learn, share knowledge, and build your career. Connect and share knowledge within a single location that is structured and easy to search. There's a plugin for the Contact us form. My page is calling a page template. Look here for more: Do Shortcode. Check the documentation for more. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. How can I call a WordPress shortcode within a template?
How to Use WordPress do_shortcode?
What Exactly is Shortcode?
Resources Blog. Usually, site owners will modify theme files to create a desired effect. However, some people find placing snippets into posts and pages to be more ideal given certain situations. I still advise making certain changes directly from theme files , but this method works exceptionally well in many instances.
Using the WordPress do_shortcode function
Extending site functionality is easy with the help of shortcodes. Here, we will show you how to apply it. Shortcode is a snippet of code, which allows you to execute a function like displaying content. It allows you to embed the shortcode anywhere you want — including the header. To apply this function, you need to access and tweak the theme files. To do so, use the following steps:. Sometimes, editing theme core files can break your WordPress template. To solve it, you should alter the CSS to make your website look better.
Konstantinos Kouratoras is a software engineer based in Crete, Greece. WordPress lover and amateur photographer. When a shortcode is inserted in a WordPress post or page, it is replaced with some other content. In other words, we instruct WordPress to find the macro that is in square brackets  and replace it with the appropriate dynamic content, which is produced by a PHP function. The usage is pretty simple. We could use something like this:. For a more advanced shortcode, we could set the number of posts to display by setting a parameter:. The creation process is simple and does not require any advanced PHP knowledge.