A shortcode will need to be put in the post/page, not in the template files.
To use shortcodes in template files, you need to use the do_shortcode() function.
https://codex.wordpress.org/Function_Reference/do_shortcode
Thanks Rhys,
I just got support from my host to fix the problem and its happened again. What the hell is wrong with this? My site is unreachable now. I can’t even get into the WP editor and this is the 3rd time!
I entered <?php echo do_shortcode(‘[shortcode]’); ?> into functions.php and my site is bloody broken.
error
Parse error: syntax error, unexpected ‘<‘ in /home/xxxxxx/public_html/wp-content/themes/nerocity/functions.php on line 15
Seriously, can I not just put in a request for someone to help me do this. I’m trying to run events and can’t with no website 🙁
Apologies I’m just getting frustrated.
It’s impossible to tell without seeing the whole file, but remove that line <?php echo do_shortcode('[shortcode]'); ?>
Do shortcode doesn’t usually work in functions.php. It should be placed in other template files (i.e. single.php for single pages).
What are you actually wanting to do?
Your PHP do_shortcode will not actually say do_shortcode. That is just a placeholder for the actual function that you will put there.
However, I got the feeling you wanted to know how to put a shortcode on the HTML page in your dashboard. To do that, you would just go to where you normally enter text, in the Text view, and type [shortcode]. BUT–you don’t actually type the word shortcode! You type the command that the specific plugin gives you.
For example, when I want to use the Stripe plugin, I will type [stripe] and it will appear. When I am running my events calendar, I will type [calendar]. It depends on the plugin.
Again, this will only work on pages when you are logged into your dashboard. It won’t work in a PHP file.
Er, I beg your pardon. Your PHP WILL say do_shortcode but the name of the shortcode within the parentheses and quotes will depend on the plugin. It will not actually say ‘shortcode’. Hope that didn’t confuse anybody.
Thanks for the help, I’m scared to try things since I keep breaking but I have restores I guess.
I’m learning HTML, PHP, CSS etc but just started. I want to do this as a career(web dev) and I will learn it however, this site is for my own personal use, a gaming community that puts on events and I don’t want the community to have to wait for me to learn all this before they get to use what is essentially a new look site going from free hosting to paid hosting.
I have my phpbb forum waiting(thats not going to cause me much headache but I just want a few simple-ish things on my current homepage then I have 3 other wordpress pages to do. One page at a time though, WP and my front page is nothing like editing pre-written HTML and CSS, which is what I am used to on my freeforum. Php, well I’ve never seen it until WP and I went paid.
Thanks again