Skip to content

Instantly share code, notes, and snippets.

@DerekCaelin
Forked from Shelob9/pods-template-filter.php
Last active December 21, 2018 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerekCaelin/9a5371a6dfc076810483253aec9dc7d2 to your computer and use it in GitHub Desktop.
Save DerekCaelin/9a5371a6dfc076810483253aec9dc7d2 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: Pod Template
PluginURI: https://gist.github.com/Shelob9/7540721
Author: Josh Pollock
AuthorURI: http://JoshPress.net
Modified by: Derek Caelin
*/
function slug_pods_content_filter($content) {
if ( get_post_type() == 'tool' ) {
$obj = pods('tool', get_the_id() );
return $obj->template('tool').$content;
}
if ( get_post_type() == 'tooltype' ) {
$obj = pods('tooltype', get_the_id() );
return $obj->template('tooltype').$content;
}
if ( get_post_type() == 'tool-objective' ) {
$obj = pods('tool-objective', get_the_id() );
return $obj->template('tool-objective').$content;
}
if ( get_post_type() == 'support-org' ) {
$obj = pods('support-org', get_the_id() );
return $obj->template('support-org').$content;
}
if ( get_post_type() == 'support-org-type' ) {
$obj = pods('support-org-type', get_the_id() );
return $obj->template('support-org-type').$content;
}
if ( get_post_type() == 'de-post' ) {
$obj = pods('de-post', get_the_id() );
return $obj->template('depost').$content;
}
if ( get_post_type() == 'campaign' ) {
$obj = pods('campaign', get_the_id() );
return $obj->template('campaign').$content;
}
if ( get_post_type() == 'activity-report' ) {
$obj = pods('activity-report', get_the_id() );
return $obj->template('activity-report').$content;
}
return $content;
}
add_filter( 'the_content', 'slug_pods_content_filter' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment