/** * Attach Pods Template to $content * * @param string $template_name The name of a Pods Template to load. * @param string $content Post content * @param Pods $pods Current Pods object. * @param bool|string $append Optional. Whether to append, prepend or replace content. Defaults to true, which appends, if false, content is replaced, if 'prepend' content is prepended. * * @return string $content with Pods Template appended if template exists * * @since 2.4.5 */ function load_template($template_name, $content, $pods, $append = true) { //prevent infinite loops caused by this method acting on post_content remove_filter('the_content', array($this, 'front')); $template = $pods->template($template_name); add_filter('the_content', array($this, 'front')); //check if we have a valid template if (!is_null($template)) { //if so append it to content or replace content. if ($append === 'replace') { $content = $template; } elseif ($append === 'prepend') { $content = $template . $content; } elseif ($append || $append === 'append') { $content = $content . $template; } else { $content = $template; } } return $content; }