Place a URL parameter value inside a WordPress short code

If it is a shortcode you’re developing yourself, then you could add the url parameter checking / getting for example like this, add_shortcode( ‘EmbedMe’, ’embedme_callback’ ); function embedme_callback( $atts ) { $defaults = array( ‘file’ => ” ); $atts = shortcode_atts( $defaults, $atts, ‘EmbedMe’ ); if ( ‘source’ === $atts[‘file’] && ! empty( $_GET[‘source’] ) … Read more

How can I custom order the product display?

You can use woocommerce_shortcode_products_query filter to change orderby argument. it will set orderby as post__in in [products] shortcode query. I have tested and it is working fine for me. you can take reference from below code and adjust code as per your need. Let me know if this works for you! add_filter( ‘woocommerce_shortcode_products_query’, ‘woocommerce_shortcode_products_orderby_post_in’ ); … Read more

Shortcode multiple values

you can make a string and parse it. you start with [foo people=”name:john,age:51|name:jenny,age:62″ something=”custom”] and you use this code add_shortcode(“foo”, function ($attr, $content, $tag) { // parsing attributes $attr[“people”] = explode(“|”, $attr[“people”]); $attr[“people”] = array_map(function ($e) { $tab = []; foreach (explode(“,”, $e) as $raw_tab) { $tab2 = explode(“:”, $raw_tab); $tab[$tab2[0]] = $tab2[1]; } return … Read more

Using shortcode content with nested shortcode

You don’t have to use do_shortcode inside your shortcode callback function. But if you don’t do this, then you won’t be able to nest shortcodes, so other shortcodes added on the site won’t work inside it. Let’s say your shortcode callback looks like this: function a_shortcode($atts = [], $content = null) { //use content here, … Read more

WordPress Vue Js Shortcodes

After a while i got it : In the functions.php i added the line : wp_localize_script(‘vue_wordpress.js’,’sharedData’,array( ‘contactForm’ => do_shortcode(‘[contact-form-7 id=”5″ title=”Formulário de contacto 1″]’) ) to the already existing function i had: function vue_wordpress_scripts() { // Styles wp_enqueue_style( ‘style.css’, get_template_directory_uri() . ‘/style.css’ ); // wp_enqueue_style(‘vue_wordpress.css’, get_template_directory_uri() . ‘/dist/vue-wordpress.css’); // wp_enqueue_style(‘global’,get_template_directory() . ‘/styles/menu.css’ ); //copiar este … Read more