Custom Shortcode with Dynamic Button

This may not be a direct answer to your shortcode issue. But try doing it as a post template, from there its easier to handle post data. You have a working button below the description. Copy it and place it on the bottom. And use Class to trigger your JS this time.

If do_shortcode is blank, return some message

From several version of WordPress, it’s better to use https://developer.wordpress.org/reference/functions/apply_shortcodes/ io do_shortcode. That said you can surely do something using has_shortcode() https://developer.wordpress.org/reference/functions/has_shortcode/

loop on page makes shortcode fail

You really shouldn’t use query_posts() for anything other than the main loop of that page and use either WP_Query() or get_posts(), try this: $my_query = new WP_Query( array( ‘category_name’ => ‘interesting_sites’, ‘posts_per_page’ => 3, ‘orderby’ => ‘rand’ ) ); while ($my_query->have_posts()){ $my_query->the_post(); ?> <div <?php post_class(); ?>> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div> <?php … Read more

How to attach sidebar to shortcode’s output?

I’m still not sure exactly what you’re trying to do, but here’s one possibility if it’s to display something like this: PAGE CONTENT | SHORTCODE/POSTS LOOP | SIDEBAR Do you have control of the shortcode content? If so, you could update it so its output is wrapped in a <div id=”shortcodecontent”> –shortcode post-loop output– </div>. … Read more

Can’t get default values to work with custom shortcode

extract takes and associative array and explodes it out in variables that reflect the array key names. $atts[‘height’] would just be $height, in other words. The relevant two lines of your code would become: <param name=”type” value=”video/quicktime” height=”‘.$height.'” width=”‘.$width.'”> <embed src=”‘.$url.'” height=”‘.$height.'” width=”‘.$width.'” autoplay=”false” type=”video/quicktime” pluginspage=”http://www.apple.com/quicktime/download/”> If you did still want to use the indexing, … Read more

Shortcode Variations?

function btn($atts, $content = null) { extract(shortcode_atts(array(‘link’ => ‘#’, ‘color’ => ‘teal’ , ‘size’ => ‘large’), $atts)); return ‘<a class=”btn ‘.$size.'” href=”‘.$link.'” style=”background:’.$color.’;”><span>’ . do_shortcode($content) . ‘</span></a>’; } With that function you get by default color teal and size large. I suppose that for size you are using classess and for color just background. If … Read more

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