Shortcode onClick Ajax
-
Hello,
The plugin works like a charm, thanks for that.
I’m using it to create a download link for each entry of a list of attachments from the media library.
I had to include an onclick action for Ajax purposes (tracking downloads). So I modified the plugin output a bit, from
return sprintf( '<a href="%1$s" class="%2$s">%3$s</a>', esc_url( $url ), esc_attr( $class ), esc_attr( $label ) );
to
return sprintf( '<a href="%1$s" class="%2$s">%3$s</a>', esc_url( $url ), esc_attr( $class ), esc_attr( $label ), get_the_ID(), get_current_user_ID() );
around line 141 of download-shortcode.php.
It still does the trick, the URL includes the relevant onClick and the shortcode works.
But I also had to filter the list by category and used an Ajax action (‘load-filter’) for that.
When the new filtered list is displayed in Ajax, get_the_ID() doesn’t work anymore.
An idea about how to fix that ?
Thanks
- The topic ‘Shortcode onClick Ajax’ is closed to new replies.