Shotcode error on functions

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, the only one in your case, needs to be an action hook name. If you pass it a valid hook name and have a function attached to that hook, this code … Read more

Shortcode conversion to hrml when post is published

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

Display Current Time using shortcode

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

Shortcode with foreach

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

Shortcode content is empty [closed]

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.

Shortcode leads to white screen [closed]

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