Shotcode error on functions

Hello i have this shortcode that is generating a error. Can someone help? add_shortcode(‘do-action’, ‘do_action_shortcode’); function do_action_shortcode($atts, $content = ”) {   ob_start();   do_action($content);   $out = ob_get_contents();   ob_end_clean();   return $out; } Answer do_action is a WordPress function for running action hooks. I assume that is what you are trying to do. Given that, The first parameter, … Read more

Set variable in javascript and using in my shortcode

my script is function($) { var google_map_address = $(‘#address’).text(); $(function () { $(‘#gmap’).gmap3({ marker: { address: google_map_address }, map: { options: { zoom: 14 } } }); });})(jQuery); and my php code is init_shortcode(); function init_shortcode() { $shortcodes = array( ‘gmap’ => ‘spyrowebs_gmap’); foreach( $shortcodes as $tag => $func ) add_shortcode( $tag, $func ); } … Read more

Subtract Using GravityWP Count Plugin

I’m currently using GravityWP Count plugin for entry totals on number fields. To this end I also needed to subtract totals via a shortcode. I reached out to the plugin author who kindly responded but I’m sure has other things to do. if (class_exists(“GFForms”)) { function gravitywp_count_func( $atts, $content = null ) { extract( shortcode_atts( … Read more

How to stop an image link continuing to link adjacent text from a shortcode?

I want to keep an image link to just the image, but it runs on to the adjacent text. I have an image that I attached a link to and made it into a shortcode: function data_integrity(){ return ‘<a target=”_blank” href=””> <img style=”float: right; margin: 0px 10px 10px 10px;” src=”” </a>’; } add_shortcode(‘shield’, ‘data_integrity’); I’m … Read more

Display Current Time using shortcode

I am using the below code to display current time in php supported time zones: <?php date_default_timezone_set(‘Asia/Kolkata’); $currentTime = date( ‘d-m-Y h:i:s A’, time () ); echo $currentTime; ?> We need to create few different pages in wordpress to display current time in different supported cities / timezones in wordpress pages through shortcodes in following … Read more

Shortcode with foreach

I can’t use shortcode with foreach. It gives me syntax error. Where i am wrong? function create_galeri_shortcode($atts) { $atts = shortcode_atts( array( ), $atts, ‘galeri’ ); if ( has_post_format( ‘gallery’ )) { $images = get_post_meta(get_the_ID(), ‘vdw_gallery_id’, true); if($images) { $out = ‘<div id=”lightgallery”>’. foreach ($images as $imageid) { $altyazi = get_post_meta( get_the_ID(), ‘_wp_attachment_image_alt’, true ).’ … Read more