Make shortcode’s Bootstrap CSS override the theme’s CSS, how?

Ok, I think I solved: followed this discussion so I imported Bootstrap SASS file in a new SASS file creating a custom class as container to isolate Bootstrap components and compiled the custom .scss to .css. Fixed html and body selector in new CSS file and to have working tooltips I did: $(‘[data-toggle=”tooltip”]’).tooltip({ container: ‘.custom-container’, … Read more

Two different inner shortcode under shortcodes or multiple nesting of inner shortcodes

Yes, you can keep nesting shortcodes. Just keep using the do_shortcode() until the deepest level is reached. https://codex.wordpress.org/Shortcode_API#Nested_Shortcodes So you can do this, [container] [other_column class=”extra-class”] [content] col 1 [/content] [another] col 1-2 [/another] [/other_column] [column] [another] col 2 [/another] [/column] [/container] To achieve output like this, <div class=”container”> <div class=”other-column extra-class”> <div class=”content”> col … Read more

Display first name of logged in user?

The issue here is that both the functions have the same name – colaborator_avatar(). Make sure that $new_user contains the current user. Else use get_current_user_id() like this: get_user_meta( get_current_user_id(), ‘first_name’, true ); Show avatar and first name: // show user avatar if logged in function colaborator_avatar($atts) { if (is_user_logged_in() && !is_feed()) { return get_avatar(get_the_author_meta( ‘user_email’ … Read more

Show history of post revisions on front end

Your shortcode calls wp_list_post_revisions() which echo the output (revision list), hence you get the “updating error”. To fix the issue, you can use output buffering like so: ob_start(); wp_list_post_revisions( get_the_ID() ); $revisions = ob_get_clean(); Or you could use wp_get_post_revisions() and build the HTML list manually. Here’s an example based on the wp_list_post_revisions(): $output=””; if ( … Read more

Create shortcodes within foreach loop (using array)

Solved issue of dynamic function name by using $shortcode var as function name foreach ($shortcodes as $shortcode) { add_shortcode($shortcode, function ($atts) use ($shortcode) { $filepath = str_replace(‘_’, ‘-‘, $shortcode); ob_start(); require_once(get_stylesheet_directory() . ‘/template-parts/’ . $filepath . ‘.php’); return ob_get_clean(); }); }

Convert HTML Script to Shortcode [closed]

Your JavaScript targets a HTML element with the id ‘banner_div’. So the first step is to output such an element in the shortcode. add_shortcode( ‘shortcode_name’, function () { $out=”<div id=”banner_div’></div>’; return $out; } ); Now you need to save the JavaScript (everything between the <script> tags) as a file. This you can now enqueue which … Read more

How to display Custom Post Type Post based on Tag with Shortcode Parameter?

This is an answer that depending on how you ultimately configure things – should get you where you want to go. In your question, you had posts_per_page as 1. If you only want 1 result, then that’s fine. If not… modify as shown. You also didn’t initialize the concatenated string $return_string and finally you put … Read more

How to link to current post in WordPress?

This is exactly the type of scenario shortcodes are intended for. Simply add the following to your theme’s functions file to create the shortcode: add_shortcode( ‘this_permalink’, ‘this_permalink’ ); function this_permalink($atts, $content){ return ‘<a href=”‘. get_the_permalink() .'”>Link to this article</a>’; } .. and use this in your post to render the link: [this_permalink] I cannot think … Read more