I forgot to post here after encountering this myself. As others have found, setting the view template in the normal way apparently doesn't work, but my solution was a bit different.
Rather than setting the _views_template when creating or updating the post, I'm setting it with a filter when displaying a particular post type. So my code doesn't actually affect Gravity Forms at all. It seems like this has a few advantages for my particular situation. It doesn't matter which form created the post (in case you want to have totally different forms that create the same post type, this code will apply to all of them), and you can create a form that creates posts of multiple different post types on one form submission ( in that case you just need to have one instance of this filter for each post type).
Disclaimer: I'm not a php expert, so maybe I don't grasp all the nuances and implications of the different approaches. There may be advantages to the other approach or disadvantages to mine that I haven't noticed. I arrived at my approach by working through the Types and Views forums and my excerpt works like a charm on my site.
Thanks for posting theslink2000 - it's nice to see another approach.
Here's my code:
//Set Views Template Custom Post Type Created by GF on the Front End
add_filter('get_post_metadata', 'meter_template_filter', 1, 4);
function meter_template_filter($dummy, $post_id, $meta_key, $single) {
if ($meta_key == '_views_template') {
if (is_singular('your-custom-post-type-slug')) {
return 267; //replace 267 with the id of your views template
}
}
return null;
}
Posted 13 years ago on Friday August 10, 2012 |
Permalink