If you want to use a different template than the default page template, the only way that I know of to do it is to add code to your theme to use a different template for the campaign pages by hooking into the page_template filter. For example:
add_filter( 'page_template', 'pfund_custom_page_template' );
function pfund_custom_page_template($current_template) {
global $post;
if ( $post && $post->post_type == 'pfund_campaign' ) {
return locate_template( 'campaign-template.php' );
} else {
return $current_template;
}
}
Thanks John – I was thinking that would be the case. I will try to find someone that can help do that.
Again, I appreciate what you do. I am on Cure’s pages right now. I love what Cure does and I love the site. I am there trying to see how you lay out things and make things work -but I am more drawn into the stories – the needs and the celebrations.
Blessings,
Jerry
John, I was able to change this through CSS rather simply. I have to do it for each cause, but it works. Hope this helps someone else.
I haven’t tried this yet, because I haven’t needed it, but would it work to just add a template called: single-pfund_campaign.php to your theme directory?
hello guys , excuse my english but i am from italy
i need this to but i am not sure i understand were to ad thi filter John,
cuold you explai it to me a little better ?
thanks
Claudio
ok i did it this is the code i out in functions.php
/* for template custom*/
add_filter( 'page_template', 'pfund_custom_page_template' );
function pfund_custom_page_template($current_template) {
global $post;
if ( $post && $post->post_type == 'pfund_campaign' ) {
return locate_template( 'campaign-template.php' );
} elseif ( $post && $post->post_type == 'pfund_cause' ) {
return locate_template( 'cause-template.php' );
} else{
return $current_template;
}
}
ok John one more thing the edit shortcode shows the button but cliking it nothing happens
ciao….
With John’s and clauds54’s code pieces I was able to get my campaign to use the custom template I created, however, I also want to use a different navigation menu with this template. The code I’m using in my theme-actions.php file won’t pick up that the campaign is using this custom template.
elseif ( function_exists('has_nav_menu') && is_page_template('single-pfund_campaign.php') && has_nav_menu('golf-menu') ) {
wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'golf-menu', 'menu_class' => 'nav fl', 'theme_location' => 'golf-menu' ) );
If I switch out my single-pfund_campaign.php with another custom template I have in use, the menu is displayed properly. Is this something to do with how the template is being assigned to the pfund_campaign post type?
Thanks for any suggestions.