Shortcode Not Working in Slider When Added To Post Title

do_shortcode() returns the content you pass it with the shortcodes, if any, filtered out (ie, processed). So the code you’ve posted in your question won’t work the way you want it to: do_shortcode( get_the_title() ); printf( ‘<h2><a href=”%s” title=”%s”>%s</a></h2>’, get_permalink(), the_title_attribute( ‘echo=0′ ), get_the_title() ); Instead you’ll need to do something more like this: $title … Read more

Are Shortcode Attributes Always Passed As Strings?

Yes, shortcode attributes are always strings. WordPress has no way of knowing the intended type of each attribute, and the values are ultimately pulled from an HTML string, after all. If you need $id to be an integer, just do this: $args = ( shortcode_atts( array(‘id’ => ”), $atts ) ); $id = (int) $args[‘id’]; … Read more

Custom shortcode for displaying user based on a role parameter

First, you’ll have to get shortcode parameter(s). Change function’s declaration to: function display_user_roles( $atts ) { Your shortcode will be either [hw_display_users] or [hw_display_users role=”roletopass”]. The first (no parameter) will use role specified in $args array. Second will replace $args->role with parameter passed. Add if ( !empty( $atts[‘role’] ) ) $args[‘role’] = $atts[‘role’]; before $users … Read more

Short code template + ajax

As Tom J Nowell noted in the comments, your setup is bit wonky, which is why it won’t work. You need to add the ajax actions and register the shortcode earlier – i.e in a custom plugin or in the theme functions.php. This is related to how WordPress handles requests and in which order it … Read more

Getting Page Content Using Shortcode

First, I will add here 3 resources for learning most of the things you need about shortcodes: Official WP Docs A good article Another article that I wrote The idea is that you don’t echo the content in your shortcode, but you return it so that WordPress can only print it where it is needed. … Read more