Pass fileurl parameter into shortcode from Advanced Custom Fields

Do not use echo in your shortcode. Use return instead. function get_generic_demo() { //Get the field’s value $demo = get_field( ‘generic_demo’); //Save the URL into a variable $url = $demo[‘url’]; // Pass it to the other shortcode and return its value return do_shortcode(‘[sc_embed_player fileurl=”‘.$url.'”]’); } add_shortcode( ‘generic_demo’, ‘get_generic_demo’); Also make sure your fields contain the … Read more

Video Shortcode & Video Poster Question

There’s no straight forward way of doing this but we can achieve this with a small JS snippet. You can add the following JS snippet in your footer to make it work with all videos in your content. var videos = document.getElementsByTagName(‘video’); for (var i = 0; i < videos.length; i++) { videos[i].addEventListener(‘ended’, function(e) { … Read more

Shortcode IF statment help

I am not really sure I understand the question. You would like to display different markup depending on which fields are set in the $atts array? If this is the case, then this should work: // Check so fields are set in the `$atts` array. if (isset($atts[‘img’], $atts[‘user’], $atts[‘text’])) { return ‘<div class=”hire-equipment-item”> <div class=”hire-equipment-item-img”> … Read more

How To Render Shortcode In AJAX Response?

In general, sshortcodes are not a programming construct, they are content macros. As content macros, their viability in being used outside of their content context is limited. Simplistic shortcodes, like the gallery/audio/video (and I am not sure even about them) might “render” without context, but advanced ones will need a properly set loop, and calls … Read more

Shortcode Help Needed → attributes

You’re returning each line individually. It’s only going to output the first line since return stops execution of the function. Instead, add each line to a string by concatenating with .=: function wpse_276152_image_shortcode( $atts ) { $atts = shortcode_atts( array( ‘to’ => ‘https://pics.wikifeet.com/Melania-Trump-Feet-720891.jpg’ ), $atts ); $output=”<div class=”class1″>”; $output .= ‘<img class=”class2″ src=”‘ . $atts[‘to’] … Read more

Loop returns the current page’s permalink and guid instead of the post in the loop

I’m actually surprised that your code is working. There are several typos in it that should be throwing fatal errors. global $post; $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : ?> <?php $the_query->the_post(); $id = get_the_ID(); ?> … Read more

Beginner’s question about shortcodes

It looks like theme issue. Switch to default WordPress theme and check it. I have tested it on WordPress Twenty Seventeen theme. For testing: 1) Add below code in theme functions.php // Sample shortcode [testme] function testme_cb( $atts ) { return ‘Working? Maybe.’; } add_shortcode( ‘testme’, ‘testme_cb’ ); // Enable shortcodes in text widgets add_filter(‘widget_text’,’do_shortcode’); … Read more

add_filter img_caption_shortcode not implemented

(gotta read the docs a bit more carefully) I was using this code in the loop $xcontent =get_the_content(); But get_the_content() does not apply filters … as the documentation states (if I was paying attention). I should use the_content(), or change it to this (which is the same as the_content()) : $xcontent =get_the_content(); $xcontent = apply_filters(‘the_content’, … Read more