Passing postid of Testimonial Custom Post in Shortcode Parameter

Well, maybe you shouldn’t set $args[‘posts id’] as this is not a supported argument for the get_posts function and instead use the “posts__in” argument or instead switch to the “get_post” function if you get the id parameter. Also, i’m not quite sure but i think you have to use quotes in the shortcode. So your … Read more

using a shortcode in a hyperlink

Don’t use double quotes (“) inside the shortcode, since you are using double quotes to specify the href attribute. The browser thinks your href text ends at position=. Use single quotes instead: href=”https://wordpress.stackexchange.com/reservation/?unitrate=[print_csv position=”5′]&… I agree with the comments that there is a better way to do this, but I provide a potential answer anyway … Read more

How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes

Probably you need to create a shortcode with parameters. You should have different parameters for font size, color, bold, underline or anything else. The user should insert a value for each of these parameters in the shortcode. You can find what you need here https://developer.wordpress.org/plugins/shortcodes/shortcodes-with-parameters/ It is a little tricky though because you must check … Read more

Using $variable in shortcode

If you’re using PHP > 5.3, then you can use a closure on the the_content filter. This filter needs to be added after the $variable has been defined and before the the_content filter has fired. add_filter( ‘the_content’, function( $content ) use ( $variable ) { return str_replace( ‘[variable][/variable]’, $variable, $content ); } ); Shortcodes are … Read more

Shortcode not picking up custom field

could be a question of string concatenation – try (untested): <a href=”‘.get_permalink().'” title=”‘.get_the_title().'”><img src=”‘. get_bloginfo(‘template_directory’).’/timthumb.php?src=”.$thumb.”&h=100&w=600&zc=1&q=100&a=”.get_post_meta($post->ID, “thumbcrop’, true).'” alt=”‘.get_the_title().'” /></a>