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 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

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

How to make this shortcode work for post content wordpress [duplicate]

This will not work in the post content context because filter for wpauto is executed before the shortcodes are processed. So, your shortcode tries to disable wpauto filter, but that filter was already executed on that content. You can do with this (in theme functions.php file, and similar for excerpt): add_action(‘the_content’, ‘wse_281097_content_remove_wpautop’, 1); function wse_281097_content_remove_wpautop() … Read more

Display a form partially with a shortcode

In your function mailchimp_form_shortcode(), you need to do following changes (specifically first line inside the function): <?php function mailchimp_form_shortcode($atts) { extract(shortcode_atts(array(), $atts)); if(isset($attrs[‘type’]) && $attrs[‘type’] == ‘some_value’){ //return “form element”; } } add_shortcode(‘mailchimp’, ‘mailchimp_form_shortcode’); ?> and your shortcode will be as: [mailchimp type=”some_value”] By this, you can pass parameters to your shortcode function. And inside … Read more

How to add data attributes to the wordpress audio shortcode

They’re may be a more parsimonious way to achieve what you want, maybe with jQuery or a more heavily customized version of the code, but just keeping to WordPress core functions, you could try the following approach, which utilizes the wp_audio_shortcode_override filter. I tested a version of the below using is_page() for the main conditional. … Read more

Form shortcode with multiple options as attributes

You can use shortcode attributes in the following way: // The shortcode function function mailchimp_form_shortcode( $atts = [], $content = null ) { $attributes = shortcode_atts( array( ‘option1’ => ‘no’, ‘option2’ => ‘no’, ), $atts ); $mc_form = ‘ <div id=”mc_embed_signup”> <form action=”xxxxxxx” method=”post” id=”mc-embedded-subscribe-form” name=”mc-embedded-subscribe-form”> <div id=”mc_embed_signup_scroll”> <div class=”container”> <div class=”mc-field-group”> <label for=”mce-EMAIL”>E-mail: <span … Read more