Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created September 25, 2017 13:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/f0ab7fc2a5b145481e5d8eed526c9857 to your computer and use it in GitHub Desktop.
Save billerickson/f0ab7fc2a5b145481e5d8eed526c9857 to your computer and use it in GitHub Desktop.
<?php
/**
* Template Parts for Display Posts Shortcode
* @author Bill Erickson
* @see https://github.com/billerickson/display-posts-shortcode/wiki#using-template-parts
*
* @param string $output, current output of post
* @param array $original_atts, original attributes passed to shortcode
* @return string $output
*/
function be_dps_template_part( $output, $original_atts ) {
ob_start();
get_template_part( 'partials/archive', get_post_type() );
$new_output = ob_get_clean();
if( !empty( $new_output ) )
$output = $new_output;
return $output;
}
add_action( 'display_posts_shortcode_output', 'be_dps_template_part', 10, 2 );
@weisbeym
Copy link

Where would I put this in the plugin?

@MGParisi
Copy link

Anywhere. I think functions.php references the theme. Add this anywhere to the functions.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment