Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active June 27, 2018 19:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Shelob9/7540721 to your computer and use it in GitHub Desktop.
Save Shelob9/7540721 to your computer and use it in GitHub Desktop.
This is an example of how to append Pods Templates to content in a custom post type. For an automated version of this see: https://github.com/pods-framework/pods-frontier-auto-template
<?php
/*
Plugin Name: Pets Template
PluginURI: https://gist.github.com/Shelob9/7540721
Author: Josh Pollock
AuthorURI: http://JoshPress.net
*/
//Be sure to change 'pets' on line 6 and 9 to your cpt and template names.
function slug_pets_content_filter($content) {
if ( get_post_type() == 'pets' ) {
$obj = pods('pets', get_the_id() );
return $obj->template('pets').$content;
}
return $content;
}
add_filter( 'the_content', 'slug_pets_content_filter' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment