I just wrote a custom post (suppliers
) as a plugin (with meta content) that works great. I've also created a template page (single-suppliers.php
) within the same plugin to display the data. I wrote it in such a way that, if someone so desires, they can create their own single-suppliers.php
page in their template and get their own look and feel. (I'm using template_include
filter to do this.)
Example of the template_include filter.
// Register a my Membership Template.
function my_membership_include_template_function( $template_path ) {
if ( get_post_type() == 'my_members' ) {
if ( is_single() && is_main_query() ) {
// Check if the file exists in the theme first, otherwise
// serve the file from the plugin.
if ( $theme_file = locate_template( array ( 'single-my_members.php' ) ) ) {
$template_path = $theme_file;
} else {
$template_path = plugin_dir_path( __FILE__ ) . '/single-my_members.php';
}
}
}
return $template_path;
}
add_filter( 'template_include', 'my_membership_include_template_function', 1 );
An example of single-my_members.php
.
<?php
get_header();
?>
<h1>Test Header - Does not appear within the theme's "content" area.</h1>
<?php
get_sidebar();
get_footer();
However, the issue that I am having is that, while the content looks great within its own context, it does not sit in the correct location of my client's current theme. It sits in its own area above the start of the theme's content. See the screenshot:
After searching through WordPress documentation, I ran across the filter, the_content
, which resolves the above problem by putting the content in the correct location, but then it does not seem to allow for customization of a page should my client want to do that ( which they have indicated that they do. There's also the issue that the_content
filter appears to append. )
I'm not sure how to best resolve this or if there is a better practice that I should be using. If it helps, I am using Genesis with a child theme, but I specifically don't want to code in Genesis hooks as that would defeat the purpose of the generic plugin.