Shortcodes in Info Boxes
This support request was posted in Flatbase by trucallinglife
- trucallinglife June 30, 2016 at 7:33 am
How do I inject a short code in to the Info Boxes, I’m able to do it with posts and pages on the site but for some reason it doesn’t work when I put it in an Info Box. My assumption would be the Info Box’s weren’t given the code to parse a short code but it’s one of the easiest ways to get around missing functionality.
I would assume it’s a relatively straight forward bit of code to add the functionality to the Info Box’s but without knowing a how they are built it’s quite difficult to work out how or where.
Juanfra Aldasoro June 30, 2016 at 2:04 pmHi,
Thank you for writing, I hope you are doing well.
The reason why you are not seeing your shortcodes applied in your info boxes text is that the info boxes use a function named get_the_excerpt() to check and see if there’s actually text. That function is part of WordPress and by default it doesn’t allow shortcodes.
However, you can add this simple snippet (to the functions.php file) I’ve created and you should be able to see your shortcodes work in your infoboxes: https://gist.github.com/juanfra/e3868f044d5c09ff11f8ccc0502b9f20
Best,
Juan.trucallinglife July 3, 2016 at 10:30 amThat’s incredibly helpful thank you, one quick question though is what file would I paste that in, I’m happy doing some basic editing of PHP I usually just find it a challenge identifying ‘where’ as in which file.
Juanfra Aldasoro July 3, 2016 at 6:49 pmHi,
Thank you for the follow up.
You need to paste that code in the functions.php of your theme.
Best,
Juantrucallinglife July 4, 2016 at 6:40 amHmm, I’ve tried that but it doesn’t seem to work. I know the short code works as I’ve tested it in normal pages and in a Flatbase Article and both work fine. However when I edit the “functions.php” in the Flatbase template nothing changes, I’ve tried combinations of editing the Flatbase functions file, editing the core WordPress functions file and tried with the shortcode in both the Flatbase shortcode file and the core WordPress shortcode file.
https://www.dropbox.com/sh/pvaewxi87fa0jwd/AADoiVFkpbz3XetqBrOJ-P2Ia?dl=0
Juanfra Aldasoro July 4, 2016 at 9:59 pmHi,
Thank you for the follow up. If you check the code I’ve sent you the hook is over get_the_excerpt and you are doing it over the_excerpt, please try changing that.
Best,
Juan.
You must be logged in to reply to this topic.