0

I have had no end of trouble trying to load custom template files I create in plugins. I have got to the point where one is loading, but its like loading inside another template, if that makes sense.

I am using the single_template hook as I want these templates to be used for a single post of type funeralservices, which I have defined in my plugin.

function funeralServicePage($single) {
        global $post;
        /* Checks for single template by post type */
        if ( $post->post_type == 'funeralservices' ) {
            if ( file_exists( plugin_dir_path( __FILE__ ) . '/pages/single-funeralservices.php' ) )                {
                return plugin_dir_path( __FILE__ ) . '/pages/single-funeralservices.php';
            }
        }
        return $single;
    }

So this is working, however it is loading inside another template which has a sidebar, and i don't want to show the sidebar on these custom pages of the plugin. All I want is the Header, Footer and everything in between to be handled by my single-funeralservices.php

(I named the file that, as in another thread it said to name the file single-{custom_post_type}.php and the hierarchy will kick in and override the template, but it did not work

Example of the page can be found here - as you can see the template I want to use is within another content area, and there is a sidebar to the right

http://bmtestsite2.com/funeral-service/jane-maree-doe/

Code for the single-funeralservices.php page

<?php

/**
 * Template Name: Service Page
 * Template Post Type: funeralservices
*/

//$quoteId = get_query_var('quote');
$siteUrl = get_site_url();

$customInfo = get_post_custom(get_the_id());

get_header();

?>
<div class="fs-container">
    <div class="fs-row">
        <!-- Message -->
        <h1>In Loving Memory of Jane</h1>
    </div>
    <div class="fs-row">
        <!-- Spacer Image -->
    </div>
    <div class="fs-row">
        <div class="fs-33">
            <div class="person-nickname">
                JaDoe
            </div>
            <div class="person-image">
                <img src="<?php echo $customInfo['person-picture'][0]; ?>">
            </div>
            <div class="person-name">
                Jane Maree Doe
            </div>
            <div class="person-dates">
                27th February 1923 - 12th APril 2020
            </div>
        </div>
        <div class="fs-66">
            <div class="fs-row">
                <div class="fs-50">
                    Service SHeet
                </div>
                <div class="fs-50">
                    Live Service
                </div>
            </div>
            <div class="fs-row">
                <div class="fs-50">
                    Life In Pictures
                </div>
                <div class="fs-50">
                    Special Tributes
                </div>
            </div>
        </div>
    </div>
</div>


</div>

<?php

get_footer();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.