Set variable in javascript and using in my shortcode
Hey Guys i got the solution. just include my script in footer instead of header. add_action(‘wp_footer’, ‘spyrowebs_gmap_enqueue_scripts’);
Hey Guys i got the solution. just include my script in footer instead of header. add_action(‘wp_footer’, ‘spyrowebs_gmap_enqueue_scripts’);
You can use the pre_post_update filter hook to achieve this. Unfortunately the Codex isn’t very good for this hook, but it’s a simple enough one to understand and can be found in wp-includes/post.php on line 3335 (WP 4.1). add_filter( ‘pre_post_update’, ‘my_replace_shortcode’, 2, 99 ); function my_replace_shortcode( $post_id, $data ){ if(strpos($data[‘post_content’], ‘[myshorcode param1=”‘) !== false) : … Read more
You forgot the image tag as well… return ‘<a target=”_blank” href=”https://openforestry.org/validity-integrity”> <img style=”float: right; margin: 0px 10px 10px 10px;” src=”https://openforestry.org/wp-content/uploads/2017/08/data_integrity.png”> </a>’;
Add this code in Theme function file functions.php function timeZone_funch( $atts ) { extract(shortcode_atts(array(‘timezone’ => ‘Asia/Kolkata’), $atts)); /* Asia/Kolkata is default Timezone */ $output=””; if (in_array($timezone, DateTimeZone::listIdentifiers())) { date_default_timezone_set($timezone); $currentTime = date( ‘d-m-Y h:i:s A’); $output = $currentTime; } else { $output = “Invalid Timezone”; } return $output; } add_shortcode( ‘current_time’, ‘timeZone_funch’ ); USAGE: [current_time … Read more
Would need to know how you are planning to use this shortcode because doing what you are asking raises the issue of what you want the shortcode to do if the user has multiple orders? If this shortcode is going to be displayed on a page or post that is specific to a specific order … Read more
You’re trying to concatenate a foreach statement in to a string, which can’t be done… You need to add the output that you need to your existing string, not concatenate it function create_galeri_shortcode( $atts ) { $atts = shortcode_atts( array( ), $atts, ‘galeri’ ); if ( has_post_format( ‘gallery’ ) ) { $images = get_post_meta( get_the_ID(), … Read more
It is the hyphen: Take caution when using hyphens in the name of your shortcodes. In the following instance WordPress may see the second opening shortcode as equivalent to the first (basically WordPress sees the first part before the hyphen): Rename your shortcode so the tag doesn’t have a hyphen.
As I already stated in comments, your code is a complete mess and very hard to read and to debug. This is most probably why you are having a hard time to sort your issues. Apart from a few syntax errors, you had a couple of bugs in your code like undefined variables (like your … Read more
Why don’t you use something like: Bla bla bla [shortcode postID=”100″ content=”Special bla bla”] Bla bla and then retrieve your content in your shortcode function. extract( shortcode_atts( array( ‘content’ => ”, ), $attr ) ); echo ‘special content is: ‘.$content;
Well, maybe you shouldn’t set $args[‘posts id’] as this is not a supported argument for the get_posts function and instead use the “posts__in” argument or instead switch to the “get_post” function if you get the id parameter. Also, i’m not quite sure but i think you have to use quotes in the shortcode. So your … Read more