Adding shortcode closing tag after a loop

Collect all of the loop’s output in a variable, wrap it in the accordion shortcode, then pass that through do_shortcode: $output=””; if ( have_posts() ) : while ( have_posts() ) : the_post(); $output .= ‘<div class=”col-lg-12 col-md-12 col-sm-12 col-xs-12″>’; $output .= do_shortcode(‘[su_spoiler title=”‘.get_the_title().'” open=”no” style=”default” icon=”plus” anchor=”” class=””]’.get_the_content().'[/su_spoiler]’); $output .= ‘</div>’; endwhile; else : $output … Read more

WP_Query is printing out only one post when posts_per_page is set to multiple

you are re-initializing the out variable that is why it shows only one product // Custom Post Type for Use Cases page slider function create_post_type() { register_post_type( ‘use_cases’, array( ‘labels’ => array( ‘name’ => __( ‘Use Cases’ ), ‘singular_name’ => __( ‘Use_Case’ ) ), ‘public’ => true, ‘has_archive’ => true, ) ); } add_action( ‘init’, … Read more

How to limit the content coming from wordpress shortcodes?

It’s better to 1st save the returned XML to a file and then loop back to unset. <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => “http://www.cpac.ca/tip-podcast/jwplayer.xml”, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => “”, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => “GET”, CURLOPT_HTTPHEADER => array( “cache-control: no-cache”, “postman-token: 28025ee8-1e82-ce60-f6ae-f401118baa1c” ), )); $response = … Read more

Autogenerate shortcodes from an array of strings

Your shortcode name (‘$name’ ) is invalid. If you want to use the variable, it should be add_shorcode( $name, …. Also, the function name is invalid. Since you want to make it “dynamic” (I’m assuming you want it to be {$name}_sc, then maybe you should use an anonymous function. What you have is somewhat unconventional … Read more

Register visits of my pages in wordpresss

It’s not a good idea to store user’s data on a file that is publicly accessible. A better way would be to create a folder, and store your file under it. Also, it’s better to use WordPress’s filesytem class rather than directly using PHP’s built-in functions. Here’s a quick fix: function wpse381320_after_login( $atts ) { … Read more

ShortCode and extra

I discover that it’s a know bug, and will be fix in future release Reference here So then, i used this code… not pretty, but do the magic !, thanks $content = do_shortcode( shortcode_unautop( $content ) ); if ( ‘</p>’ == substr( $content, 0, 4 ) and ‘<p>’ == substr( $content, strlen( $content ) – … Read more

WordPress Shortcode wrap around div

If by template file you mean a php file in the themes folder, you can call do_shortcode to have the shortcode processor do its magic on your div. EDIT: not entirely sure I understand what you want, but you could try this: <div id=”subscription”> <?php do_shortcode(‘[subscribe]’.call_php_function().'[/subscribe]’);?> </div>