Image Shortcode from ACF ID

It’s because you have forgot to use $atts[‘post_id’] please find below code. function acf_featured_item_shortcode( $atts ) { // Attributes $atts = shortcode_atts( array( ‘post_id’ => ”, ), $atts ); $post_id = $atts[‘post_id’]; $image = get_field(‘featured_item’, $post_id ); $size=”medium”; // (thumbnail, medium, large, full or custom size) if( $image ) { $output = wp_get_attachment_image( $image, $size, … Read more

Shortcode with PHP issue “Undefined index”

It’s because if the user enters large=”true”, then $atts[‘small’] isn’t defined. The normal solution is to use shortcode_atts() to set default values for the parameters, but you’re not putting the result of shortcode_atts() into $atts, you’re just just extracting it. This means that $small will be defined, but $atts[‘small’] won’t be. The proper way to … Read more

Use $_GET inside a shortcode print empty Array

$_GET is a glob var. which is triger/created when you’re sending html form data og visit a link. When is send from form you can add the needet info in “action” atr. But from youre example i see onlu that you return from the function some string…did not see the part of adding it to … Read more

Using shortcode in template file

the_post_thumbnail() echos the thumbnail and returns nothing. You probably want to use get_the_post_thumbnail() which returns it as a string. Your code currently is equivalent to this: if (has_post_thumbnail()) { // Echo the thumbnail the_post_thumbnail(); // Apply the filter but do nothing with the result. apply_filters( ‘the_content’, “[frame_left]”.”[/frame_left]”); } if (has_post_thumbnail()) { // Echo the thumbnail … Read more

shortcode help require

Here you go: add_shortcode(‘latest_tweets’, ‘latest_tweets’); function latest_tweets($atts){ extract(shortcode_atts(array( ‘max’ => 5 ), $atts)); $twitter_id = esc_attr(strip_tags($atts[0])); // try to get data from cache to avoid slow page loading or twitter blocking if (false === ($output = get_transient(“latest_tweets_{$twitter_id}”))): $doc = new DOMDocument(); $feed = “http://twitter.com/statuses/user_timeline/{$twitter_id}.rss”; $doc->load($feed); $output = “<ul>”; $i = 1; foreach ($doc->getElementsByTagName(‘item’) as $node) … Read more