Two Shortcodes in one page not working
I simply replaced require_once dirname( __FILE__ ) . ‘/swt_mm_single_box.php’; with define(‘__ROOT__’, dirname(__FILE__)); include __ROOT__.’/swt_mm_single_box.php’; and now its worked for me. check Here
I simply replaced require_once dirname( __FILE__ ) . ‘/swt_mm_single_box.php’; with define(‘__ROOT__’, dirname(__FILE__)); include __ROOT__.’/swt_mm_single_box.php’; and now its worked for me. check Here
If you are outside the loop then you can use to get them by post id, you can play around with these snippet: shortcode for author’s name: function author_name_shortcode(){ global $post; $post_id = $post->ID; $author = get_the_author($post_id); return $author; } add_shortcode(‘post_author’,’author_name_shortcode’); shortcode for categories name: function category_name_shortcode(){ global $post; $post_id = $post->ID; $catName = “”; … Read more
When no attribute is used but a value is provided, the value is added to $atts[0]. Using $atts[0], I’m now able to get the value output doing the following: function audio_shortcode($atts) { if($atts[0] != ”) { return ‘ <div class=”audiofile”> <audio controls> <source src=”‘ . $atts[0] . ‘” type=”audio/mpeg”> </audio> </div>’; } } add_shortcode(‘audio’, ‘audio_shortcode’);
Figured it out. Embed shortcode stores the oemebd data as post meta using md5 hash. wp-includes/class-wp-embed.php // Check for a cached result (stored in the post meta) $key_suffix = md5( $url . serialize( $attr ) ); $cachekey = ‘_oembed_’ . $key_suffix; $cachekey_time=”_oembed_time_” . $key_suffix; And has a cache mechanism to fetch new data only after … Read more
Simply follow the link to the has_shortcode() documentation in the last answer to the duplicate question. There you’ll find: function custom_shortcode_scripts() { global $post; if ( is_a( $post, ‘WP_Post’ ) && has_shortcode( $post->post_content, ‘custom-shortcode’) ) { wp_enqueue_script( ‘custom-script’); } } add_action( ‘wp_enqueue_scripts’, ‘custom_shortcode_scripts’); For styles this would be: function custom_shortcode_styles() { global $post; if ( … Read more
the destination-email attribute requires an additional filter to be hooked to work, as detailed in cf7 doc and this forum thread, you need to ensure you do the following 4 steps: 1) in addition to the short code attribute, [contact-form-7 id=”123″ title=”Contact Form” destination-email=”[email protected]”] 2) you need to, add_filter( ‘shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter’, 10, 3 ); function … Read more
First Add a normal Shortcode block and type the shortcode [foo]123[/foo] Then click More Options for the block and select Add to Reusable Blocks Then provide a name as Foo Next, time you can search and add the Foo block instead of typing the shortcode Thanks
Ok so by now I’ve found a plugin that does exactly what I need, its called skip to Timestamp so basically it allows to use a shortcut or even just interpretate timecodes like 1:00 to make the video go straight to that point. It works perfectly with youtube videos but it also works with and … Read more
The year, monthnum, day and w (week) parameters are only used to highlight/pre-select the current item in the list/output and they only take effect on an archive page like date and category archives. And by “highlight”, I mean WordPress will add either selected=’selected’ (if the format is option) or aria-current=”page” (for other format than link) … Read more
Yes and no I created a shortcode named foo: add_shortcode( ‘foo’, ‘fooshort’ ); function fooshort( $atts ) { return “https://google.com”; } Then put this in a post: test [foo] The result: test https://google.com So if I take your question literally, yes, you can put shortcodes in anchor attributes. But the shortcode has no idea it’s … Read more