Shortcode to delete post from front end

Following is the reformatted version of your code. get_delete_post_link() is used for fetching delete post URL so that we dont have to worry about nonce stuff. global $post is kept to avoid PHP notice which is currently there in your code. Please check it. function wpso_delete_my_posts() { global $post; ob_start(); if ( current_user_can(‘delete_posts’, $post->ID ) … Read more

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

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

stop shortcode stripping in category and archive pages

Shortcodes are stripped from the excerpt before filters are applied. Try something more like this: function tsc_execute_shortcodes_in_excerpts( $text, $raw_text ){ if(empty($raw_text)){ $text = get_the_content(”); $text = apply_filters(‘the_content’, $text); $text = str_replace(‘]]>’, ‘]]&gt;’, $text); $text = strip_tags($text); $excerpt_length = apply_filters(‘excerpt_length’, 55); $excerpt_more = apply_filters(‘excerpt_more’, ‘ ‘ . ‘[…]’); $words = preg_split(“/[\n\r\t ]+/”, $text, $excerpt_length + 1, … Read more

get_shortcode_regex() only matches first shortcode

From PHP docs (emphasis mine): preg_match() returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match. preg_match_all() on the contrary will continue until it reaches the end of subject.

Stop auto formatting in shortcodes

You can postpone the wp_autop filter which is responsible for wrapping elements in P tags till after shortcodes are rendered: remove_filter( ‘the_content’, ‘wpautop’ ); add_filter( ‘the_content’, ‘wpautop’ , 12);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)