Wordpress Shortcode syntax - wordpress

I am using the Avada theme on my WordPress which makes use of Countdown Boxes, constructing pages using the provided Fusion Page Builder. The countdown box will show the number of days to a certain date which is output through a plugin called Days-Until. Syntax for implementing this: [days_until date="15 April 2015"].
I am trying to use this Days-until shortcode and pass the value to the countdown box shortcode using the Fusion (WYSIWYG Editor):
[counters_box columns="4" color="" title_size="" icon_size="" body_color=""
body_size="" border_color="" class="" id=""][counter_box value="[days_until
date="4 April 2015"]" unit="" unit_pos="suffix" icon="" direction="up"]"
unit="" unit_pos="suffix" icon="" direction="up"]Text[/counter_box]
Unfortunately the code doesn't work, and the following is displayed.
0 (in the counter box)
unit=”” unit_pos=”suffix” icon=”” direction=”up”]” unit=”” unit_pos=”suffix” icon=”” direction=”up”]Text
Is it even possible to do what I'm trying to do?
Thanks

It's not possible to nest one shortcode inside another (i.e. your days_until shortcode inside the counter_box) without some programming.
It's a commercial theme so we're unable to see the original PHP code.
What'd you need to do is edit the code for counter_box so it calls do_shortcode on the value parameter.
do_shortcode is a function that expands any shortcodes in the supplied text (in the same way they are if they've been pasted into the content field of a Page or Post), so the days_until code will be converted to a number that the counter can use.
I would suggest getting in touch with the theme developer.
Further reading: WordPress Shortcode API

Related

How can I use WordPress shortcodes within a code editor?

The website I work on daily requires me to input a lot of markup via a WYSIWYG editor. The more complex a page gets though, the more of a pain it is to code everything within the WYSIWYG editor. So, often I end up temporarily editing a page-template within Atom, where I can use nice things like autocomplete, tag auto-closing and Emmett, and also get a live preview as I change them, using Codekit. Then I can just cut and paste the resulting markup into the WordPress editor. My issue is that shortcodes don't work within this process since they are not processed within the PHP file so live preview won't work.
// The wordpress editor renders this
[grid class="center-xs]Hello World[/grid]
// Like this
<div class="container">
<div class="row center-xs"> Hello World</div>
</div>
// PHP files/Atom just render it like this
[grid class="center-xs]Hello World[/grid]
Long story short, I want to edit my code in an external code editor for efficiency's sake, but I also want to use shortcodes for consistency and maintainability's sake.
Any idea how I can do that?
You can't.
You can't simply take just the contents of the WYSIWYG editor and use it as a WYSIWYG editor from Atom.
You can, however;
Take your code from your WordPress WYSIWYG editor.
Put it into your editor, Atom.
Edit it in your editor, Atom.
Put it back into your WordPress WYSIWYG editor in WordPress and save it.
Best solution
Your best bet is to create a custom page template using PHP for the specific page and then use <?php echo do_shortcode( '[grid class="center-xs]Hello World[/grid]' ); ?> inside there.

Divi Builder render html code on post type

I'm creating a website and I meet an issue with Divi / CPT UI.
I create a post type name "tente". In order to build the page with Divi builder, I add in function.php this code :
function my_et_builder_post_types( $post_types ){
$post_types[] = 'tentes';
return $post_types;
}
add_filter('et_builder_post_types', 'my_et_builder_post_types');
This is working, because I can use Divi builder in post type.
But, when I use tab element, the builder render HTML code on my website.
See what I've done :
And what it give to me on website :
I look at the Divi doc. I don't found something interesting about it.
Some of you have an idea ?
I am assuming you are on the latest version of Divi if not you need to update. Divi now allows for custom post types to get access to the builder. If you updated then do the following:
Remove the code you added above
In my case, I use CPT UI and have a post type named Doctors as shown below
Just go to Divi --> Theme options --> Builder --> Post Type Integration and make sure you Custom post type shows as Enabled as shown below
Your code might work but it's better to use the built-in way now that it exists.
Now, for the HTML problem.
Make sure you are in text mode NOT visual mode as shown below
Add the required shortcode to create 3 tabs
[et_pb_tabs admin_label="Tabs" use_border_color="off" border_color="#ffffff" border_style="solid"] [et_pb_tab title="Description" tab_font_select="default" tab_line_height="2em" tab_line_height_tablet="2em" tab_line_height_phone="2em" body_font_select="default" body_line_height="2em" body_line_height_tablet="2em" body_line_height_phone="2em"]
This is title1
[/et_pb_tab][et_pb_tab title="Managment" tab_font_select="default" tab_line_height="2em" tab_line_height_tablet="2em" tab_line_height_phone="2em" body_font_select="default" body_line_height="2em" body_line_height_tablet="2em" body_line_height_phone="2em"]
This is title2.
[/et_pb_tab][et_pb_tab title="Photos" tab_font_select="default" tab_line_height="2em" tab_line_height_tablet="2em" tab_line_height_phone="2em" body_font_select="default" body_line_height="2em" body_line_height_tablet="2em" body_line_height_phone="2em"]
This is title3.
[/et_pb_tab] [/et_pb_tabs]
This gives the following result
Now look at the above code while you are still in TEXT MODE and add your HTML where it says This is title1, This is title2 and This is title3 to populate the tabs with what you need. Hope this helps

Issue with Wordpress Contact Form 7 Plugin - Dynamic Text Extension

I use the Contact Form 7 plugin for contact forms on our site. I am using this on a WP installation with multiple sites. We have employment application forms on each site, and to identify the site when we do a REST call to our webapp, I would like to include the site_id (or blog_id, I'm unclear on which is the right name) so it can be used to reference the WP site in the other app. I installed the Dynamic Text Extension for this particular task, and this is my first attempt, based on the help docs, to add a hidden field with the blog_id:
[dynamichidden blog_id id:blog_id "CF7_bloginfo value='blog_id'"]
and end up with this:
<input name="dynamichidden-927" value="Elite Trade Painting Calgary" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" id="blog_id" aria-invalid="false" data-hasqtip="true" type="hidden">
I should note that no matter what I put in the tag, the same value comes up. I know I am editing the right form because if I delete the tag, it disappears completely – but no matter what I change, it always has the wrong value.
https://elitetradepainting.com/calgary/employment-opportunities/
My mistake was looking at the wrong page and thinking that bloginfo() returns the blog id - it doesn't. The DTX developer answered my question in WP forums and advised me to use a shortcode, so I wrote a callback that uses get_current_blog_id:
in functions.php:
function get_blog_id_callback() {
return get_current_blog_id();
}
add_shortcode('get_blog_id', 'get_blog_id_callback');
Then the snippet for the control in the Edit Contact Form page is as simple as:
[dynamichidden blog_id "get_blog_id"]

Where can WordPress (self-installed) shortcodes be rendered?

I've looked around for this but can't seem to find a definite answer. I want to know where WordPress shortcodes are supported within the (self-hosted) platform - meaning where can I safely place shortcode content and expect it to be rendered? I know I can use them in post and page content, and some widgets that output something. But can I use them in other plugins (that also output something), and which widgets are supported? Do custom plugins need to have something enabled that allows them to render shortcode content?
This page says:
By default, WordPress does not support shortcodes within Sidebar Widgets. It only expands the shortcodes within the content of a Post, Page, or custom post type.
... although I've gotten shortcodes to work in the arbitrary text widget, so that information doesn't seem accurate. It also suggests I install this plugin that hasn't been updated in years.
Is there any clarification somewhere on this that I've missed?
You can use:
<?php do_shortcode('name_of_shortcode'); ?>
e.g echo do_shortcode('[gallery autoplay=no]');
and it will render this shortcode. You can place it in functions.php, header.php, footer.php.
EDIT:
If you want it to work in Text Widget, all you need is to add this line of code in functions.php file:
add_filter('widget_text', 'do_shortcode');

Adding A Button Between post-content and Related Posts Thumbnail Plugin on WordPress

I am trying to add a button to my WordPress template. Basically, I have the post and then there is the Related Posts Thumbnails widget that appears. I want the button to go between the text of the post and the related posts thumbnail widget. The code in my 'Single Post' that contains all of this is as follows:
<div class="post-content">
<?php the_content(__('<em><strong>More:</strong> Read the rest of this entry...</em>', 'life-is-simple')); ?>
</div>
I know the Related Posts Thumbnails plugin falls within this code because it's at that place when I 'Inspect Element' on Google Chrome. I can't find how to edit the order of things within that div though. Any help would be greatly appreciated, thanks!
EDIT
Clarification: I am using the Life Is Simple WordPress theme although it has been custom editing quite a bit (mostly on the CSS side of things though).
That plugin is probably appending the output to the_content with a filter .
That means , that the output is being added to the_content automatically. it is a common behaviour.
You need to look at the plugin´s admin interface to see if you can have an alternative way (I believe there is ) which is using a template tag. in that case, you should put the template tag after the div where the the_content() is .
EDIT I :
After a small dig, - in fact there is - you need to put
<?php get_related_posts_thumbnails(); ?>
Then the plugin should know by itself not to append to the_content.
For parameter passing, or if something is not working, go read their APi or help files.
You'll probably need to edit single.php or archive.php in your theme. If nothing is occuring there that looks familiar, it's probably using a loop. In which case you might find what you are looking for either in loop.php, loop-single.php, or loop-archive.php depending on what type of page you are on and how the theme was constructed. Add your button near where you find Read the rest of this entry...
With more information (such as what theme you are using), one might be able to help more as well.

Resources