Combining shortcode and get_template_part

Try this function get_products($atts) { ob_start(); get_template_part(‘block-products-inline’); return ob_get_clean(); } add_shortcode(‘products’, ‘get_products’); Little explanation php just outputs your content right away when its see print statement. What we do here is, we are holding all the output in buffer and not giving it in print until the whole things finish. then we are returning the … Read more

How to display the site name in a WordPress page, or post

No, there is no core shortcode for this. The site name is available as an option, in facts get_option(‘blogname’) returns the blog name. Moreover, get_bloginfo(‘name’) / bloginfo(‘name’) can be used to get / echo the site name. Of course, you can’t use that functions as a shortcode by default, so if you want to obtain … Read more

Remove specific shortcode from get_the_content()

If you want exactly this shortcode: to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that. Here are two such examples: Example #1 /** * Let the shortcode output “almost” nothing (just a single space) for specific attributes */ add_filter( ‘wp_video_shortcode_override’, function ( $output, $attr, $content, $instance ) … Read more

Is there a way to add another row to the tinyMCE kitchen sink toggle?

Yes! Use the mce_buttons_2 filter to add buttons to the second row. Use the mce_buttons_3 filter to add buttons to the third row. Here’s an example of what I use: function mytheme_mce_buttons_row_3($buttons) { $buttons[] = ‘fontselect’; $buttons[] = ‘fontsizeselect’; $buttons[] = ‘code’; $buttons[] = ‘sup’; $buttons[] = ‘sub’; $buttons[] = ‘backcolor’; $buttons[] = ‘separator’; $buttons[] … Read more

Insert Custom HTML After Shortcode

I wonder if you could override the [rev_slider] with this kind of wrapper: add_shortcode( ‘rev_slider’, function( $atts = array(), $content=”” ) { $html=””; // Your custom banner HTML $banner=”<div id=”bannerHTML”><!– banner HTML goes here –></div>”; // Append your banner HTML to the revslider’s output if( function_exists( ‘rev_slider_shortcode’ ) ) $html = rev_slider_shortcode( $atts, $content ) … Read more

Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation

this is very simple to do… // next function next_shortcode($atts) { // global $post; -unnecessary return ‘<div class=”nav-next”>’.next_post_link( ‘%link’, ‘%title <span class=”meta-nav”>’ . _x( ”, ‘Next post link’, ‘ ‘ ) . ‘</span>’,true ).'</div>’; } add_shortcode( ‘next’, ‘next_shortcode’ ); //prev function prev_shortcode($atts) { //global $post; -unnecessary return ‘<div class=”nav-previous”>’.next_post_link( ‘%link’, ‘%title <span class=”meta-nav”>’ . _x( … Read more