How to make this shortcode work for post content wordpress [duplicate]

This will not work in the post content context because filter for wpauto is executed before the shortcodes are processed. So, your shortcode tries to disable wpauto filter, but that filter was already executed on that content. You can do with this (in theme functions.php file, and similar for excerpt): add_action(‘the_content’, ‘wse_281097_content_remove_wpautop’, 1); function wse_281097_content_remove_wpautop() … Read more

strange shortcode error: does shortcodes requires any dependency?

Problem 1 It doesn’t work because you’re using new_weber but you’re registering news_burner, and they aren’t the same So instead use: [news_burner] You only need a closing shortcode if it’s containing content which that plugin does not. Problem 2 Shortcodes don’t work in text widgets out of the box, you can add that functionality via … Read more

Function call in wordpress short code handler fails

You’re returning X(), but your X() function appears to be within a class. Presumably the same class as handleShortcode(). So you need to call it the normal way you call functions within a class: public function handleShortcode($atts) { return $this->X(); } private function X() { return ‘Hi world’; } If you’re not in a class … Read more

Display a form partially with a shortcode

In your function mailchimp_form_shortcode(), you need to do following changes (specifically first line inside the function): <?php function mailchimp_form_shortcode($atts) { extract(shortcode_atts(array(), $atts)); if(isset($attrs[‘type’]) && $attrs[‘type’] == ‘some_value’){ //return “form element”; } } add_shortcode(‘mailchimp’, ‘mailchimp_form_shortcode’); ?> and your shortcode will be as: [mailchimp type=”some_value”] By this, you can pass parameters to your shortcode function. And inside … Read more

WordPress removing slashes from shortcode output

Here is the correct shortcode function function section_shortcode_func( $atts, $content = null ){ $atts = shortcode_atts( array( ‘bgimage’ => ” ), $atts); $bgimage = isset( $atts[‘bgimage’] ) ? $atts[‘bgimage’] : ”; ob_start(); echo “<div class=”section” style=”background-image: url($bgimage)”>”; return ob_get_clean(); } Now you can call it this way [section bgimage=”xxx.xxx/wp-content/uploads/2017/10/xxx.jpg”]

dynamic site link for future migration in echo do_shortcode()

You can save your website’s URL into a variable and pass it to the shortcode: $url = site_url(); echo do_shortcode(“[timeline src=”https://wordpress.stackexchange.com/questions/284281/$url/rest-of-the-url/”]”); You should also be able to use your shortcode in the following way: echo do_shortcode(“[timeline src=””.site_url().”/rest-of-the-url/”]”);

Help Fallback (thumbnail)

This should work global $post; $html = “”; $my_latest_posts_widget = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3 )); $html .= ‘<div id=”container_recent_posts_widget” class=”container_recent_posts_widget”>’; if( $my_latest_posts_widget->have_posts() ) : while( $my_latest_posts_widget->have_posts() ) : $my_latest_posts_widget->the_post(); $thumb = get_template_directory_uri() .’/assets/images/default-image-post-thumbnail-widget.jpg’; if ( has_post_thumbnail() ) { //override fallback image if post has any thumbnail $thumb = get_the_post_thumbnail_url(); } … Read more

How to add data attributes to the wordpress audio shortcode

They’re may be a more parsimonious way to achieve what you want, maybe with jQuery or a more heavily customized version of the code, but just keeping to WordPress core functions, you could try the following approach, which utilizes the wp_audio_shortcode_override filter. I tested a version of the below using is_page() for the main conditional. … Read more