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

Need to convert image url to a Base_64 data url with wordpress function..

In your post you wrote : “which will show an image like below”, I assume that your shortcode return an img tag and you have to find your URL here, tell me if I’m wrong. Using DOMDocument http://php.net/manual/fr/class.domdocument.php to parse your img tag is a good idea. $img = do_shortcode(‘[user_meta_avatar_pic]’); // Here your get your … Read more

Portfolio Filter Buttons Wont Work

Looks like there maybe a problem with your plugins.js on line 35 according to my console. I’m getting the error TypeError: portfolioContainer.imagesLoaded is not a function. The code in question is: if (jQuery().isotope){ var portfolioContainer = jQuery(‘.w-portfolio.type_sortable .w-portfolio-list-h’); if (portfolioContainer) { portfolioContainer.imagesLoaded(function(){ portfolioContainer.isotope({ itemSelector : ‘.w-portfolio-item’, layoutMode : ‘fitRows’ }); }); jQuery(‘.w-filters-item’).each(function() { var item … Read more

Get param from shortcode in plugin function

If you have this shortcode: [product id=”2″] Which is redered by this: add_shortcode( ‘product’, ‘getSingleProduct’ ); function getSingleProduct( $atts ) { shortcode_atts( [ ‘id’ => ‘0’, ], $atts ); // Do someting with the “2”. do_request( ‘GET’, get_api_url() . ‘api/product/’ . “2” ); // This “2” comes from the shortcode } You can get the … Read more

Substite Category Slug in a Shortcode

Try this: <?php echo do_shortcode(‘[category_post_count category=’.$css_slug.’]’); ?> I’m not sure what you’re trying to do though? If you’re not doing this in actual content pages, you don’t need the shortcode. You could just do it all within the php page. Let me know if you need more info.

How to output functions from plugin inside theme

Looks like function render_content_show_hide() is a method of class. If you want access this function directly – you can create new class instance. If your plugin code looks like: class Shortcode_Builder{ //…methods public function render_content_show_hide( $attr, $content = null, $shortcode_name=”” ) { //… } //…other methods. } Create new instance $builder = new Shortcode_Builder(); And … Read more

PHP code inside Shortcode

get_field returns a value, whereas the_field echos it. You need the value to be returned into your shortcode string so do_shortcode() can read and process it. Also you need to escape the double quotes or use single quotes on fileurl= “” So, assuming preview is just the URL (and not a full HTML link) – … Read more