How to output a PHP file values by shortcode?

We’ve built shortcodes in the past using concatenating variables. To paraphrase the link above, you should output your PHP as such. $output=”<p>”; $output .= ‘<strong>’ . $content . ‘</strong>’; $output .= ‘</p>’; return $output; Note, see the .= variable concatenation.

What is the proper way to include Bootstrap when executing a shortcode

I also find the typical practice of queuing globally or from inside shortcodes problematic. I had a similar challenge with implementing code highlight on my site — I only wanted scripts and style to load as necessary. I ended up checking content for <pre> tag as condition to output: {% if ‘<pre>’ in get_the_content() %} … Read more

Order Woocommerce Products by Latest Reviewed

WooCommerce includes several options in the core plugin for sorting your products on the Shop page. However, most people don’t realize that there’s actually an option for WooCommerce custom product sorting. By default, you’re given 6 options: Default Sorting (custom + name) Popularity (sales) Average rating Most recent Sort by price (ascending) Sort by price … Read more

How to parse shortcodes within returned content

Here’s the code given by the VC team. And it works. // display content in grid add_filter( ‘vc_grid_item_shortcodes’, ‘my_module_add_grid_shortcodes’ ); function my_module_add_grid_shortcodes( $shortcodes ) { $shortcodes[‘vc_post_content’] = array( ‘name’ => __( ‘Post content’, ‘fluidtopics’ ), ‘base’ => ‘vc_post_content’, ‘category’ => __( ‘Content’, ‘fluidtopics’ ), ‘description’ => __( ‘Show current post content’, ‘fluidtopics’ ), ‘post_type’ => … Read more

Set Post Image Using Shortcode

The Shortcode API is more geared for altering post content rather than performing actions in response to content, and as such tend to require more creativity to alter other post data – though it can still be done. Ultimately, using a shortcode to set a featured image is kind of bizarre considering that you can … Read more

Different loop output every x posts in custom post type

After quite a bit of trial and error, I got the code set up correctly for the WordPress loop. I put it into a shortcode. Here it is: add_shortcode( ‘partnerlogos’, ‘display_partner_logos’ ); function display_partner_logos(){ // Define the query $args = array( ‘post_type’ => ‘dnf_partner_logos’, ‘post_status’ => ‘publish’ ); $query = new WP_Query( $args ); ?> … Read more

Change the default video shortcode

Here’s an untested way to override the output of the shortcode, with the output of your custom rtmp_video() function, when the mp4 video is hosted on amazonaws.com: /** * Override the video shortcode output for mp4 hosted on ‘amazonaws.com’ * with the rtmp_video output. * * @uses rtmp_video() */ add_filter( ‘wp_video_shortcode_override’, function( $output, $attr, $content, … Read more