Customizing gallery shortcode in 3.5

Make sure that the javascript loaded by your load-scripts.php is waiting for the document to finish loading before attaching all of the listeners. When you created a separate function the code ran only a tiny bit earlier, but it was probably early enough for the elements to finish loading and the listeners to properly attach.

Stray closing paragraph tag when using shortcodes

This is frustrating issue as I can’t depend on the content editors to be savvy enough with WordPress / HTML to understand how the text they input will be parsed… –EDIT– Having thought of this a bit more I have reconsidered my earlier answer. HTML5+ comes with the Tidy extension, if you are able to … Read more

Shortcode putting html such as

This behavior is most likely intended, and can be disabled. However it might break other features too. There are a couple of workarounds, that you can try. Break the Image URL and File Name You can pass the arguments to your shortcode in the following way: [theimg path=”https://s.w.org/about/images/logos/” filename=”wordpress-logo-simplified-rgb.png” ] This will prevent the editor … Read more

Autogenerate wordpress shortcodes using array?

Auto-generate shortcodes from an array: You can try the following Shortcode Automat: /** * Setup the Shortcode Automat * */ function shortcode_automat_setup() { $settings = array( “get_address” => “mg_admin_address”, “get_phone” => “mg_admin_phone”, “get_fax” => “mg_admin_fax”, “get_email” => “mg_admin_email”, “get_hrs_mon” => “mg_work_hrs_mon_frd”, “get_hrs_sat” => “mg_work_hrs_sat” ); $sc = new ShortCodeAutomat( $settings ); $sc->generate(); } add_action( ‘wp_loaded’, … Read more

call shortcode in javascript

Javascript code is running in the user’s browser and not on your server (where your wordpress content resides). You could use ajax to call the function which the shortcode is pointing to. Here is how I handle AJAX calls with WordPress: 1) I use a jQuery ajax function to call the wp-admin/ajax.php jQuery.ajax({ url: yourSiteUrl … Read more

How to display the names of users from a specific group with a shortcode?

Below is my own answer to the question. I will appreciate any constructive comment. add_shortcode( ‘group_members’, ‘group_members_shortcode_handler’ ); function group_members_shortcode_handler ( $atts, $content = null ) { global $wpdb; $querystr = “SELECT * FROM wp_groups_user_group”; $users = $wpdb->get_results($querystr, OBJECT); $output=””; foreach ($users as $user) { if($user->group_id == $atts[‘group_id’]){ $firstName = esc_html(get_user_meta($user->user_id, ‘first_name’, true)); $lastName = … Read more

Get all posts containing a shortcode

WordPress isn’t aware of your shortcode until it’s rendered on the front end. So when WP sees it in the content and replaces it, that’s when it’s aware that your shortcode exists. It also promptly forgets about it afterward, of course. So there’s no built in function to do what you’re asking. The best you … Read more

Make shortcode work with nested double quotes

Either way this seems like a very clunky solution for arbitrary markup in shortcode. If only one of attributes is more bulky and includes markup I would consider making shortcode enclosing: [infobox src=”http://www.google.com” title=”Google”] Some description – see more: <a href=”http://www.google.com”>More here</a> [/infobox] You might be to the point when you’ll need to built custom … Read more

How to add ‘class’ attribute into shortcode [audio]?

WordPress allows least three options to manipulate the code to your needs. Use a global variable that you increment with @Jevuska ‘s answer. global $my_audio_player_count; $my_audio_player_count = 0; add_filter( ‘wp_audio_shortcode_class’, ‘wpse221201_audio_shortcode_class’, 1, 1 ); function wpse221201_audio_shortcode_class( $class ) { global $my_audio_player_count; $class .= ‘ my-audio-player-‘.$my_audio_player_count++; return $class; } Remove the built-in shortcode and add your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)