-
-
Save billerickson/f0ab7fc2a5b145481e5d8eed526c9857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
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
Where would I put this in the plugin?