Hot answers tagged

4

For the permanent solution, your SQL query is slightly off - you need: UPDATE db1357924680.wp_posts SET post_content = REPLACE( post_content, '[print_me]', '' ) WHERE post_content LIKE '%[print_me]%' MySQL replace example


2

There is an easier way to do this: add_filter( 'the_content', 'my_post_content_remove_shortcodes', 0 ); function my_post_content_remove_shortcodes( $content ) { /* Create an array of all the shortcode tags. */ $shortcode_tags = array( 'shortcode_1', 'shortcode_2', 'shortcode_3' ); /* Loop through the shortcodes and ...


2

Run the Shortcode through do_shortcode and check what the output contains. $shortcode_content = do_shortcode( '[ninja_forms_field id=84]' );


2

Shortcodes are expected to return content, not echo it out. So if your shortcode_file.php file is straight html, it's considered being echoed. If that's the case, you could do something like : function shortcode_name(){ ob_start(); require_once ( plugin_dir_path(__FILE__) . '/shortcode_file.php'); $content = ob_get_clean(); return ...


1

Your shortcode should look something like that function se224467_shotcode_star_rating( $atts ) { $a = shortcode_atts( array( 'grade' => 5, ), $atts ); $full_stars = floor( $a['grade'] ); // full stars $output = str_repeat( '<i class="fa fa-star"></i>', $full_stars ); // if not a whole number append a halt ...


1

You are probably confused by the output of array_values() which will always get you only array values without keys while $atts variable is actually an associative array. To extract your attribute use $arr = $atts['tablepageid']; Cheers


1

To enable shortcodes in text widgets add a filter like that: add_filter( 'widget_text', 'do_shortcode' ); You can pass every string to do_shortcode() including get_theme_mod() calls. echo do_shortcode( get_theme_mod( 'theme_setting' ) );


1

You can add a Shortcode using the built-in text widget. To get the widget to process Shortcodes, add the following filter in your theme's functions.php: add_filter( 'widget_text', 'do_shortcode' ); This will result in widget text being passed thru do_shortcode, which will render any Shortcodes embedded in the text. Just note that this may not work for all ...



Only top voted, non community-wiki answers of a minimum length are eligible