Community Forums › Forums › Archived Forums › General Discussion › Ambiance Pro, adding the feature image to custom post type.
Tagged: ambiance pro, Custom Post Type, feature image
- This topic has 5 replies, 2 voices, and was last updated 10 years, 1 month ago by
David Chu.
-
AuthorPosts
-
January 28, 2015 at 12:08 am #138819
duellingpixels
ParticipantHi All,
I am after a bit of guidance, as I am a bit of a hacker when it comes to php. I am tying to replicate the feature image above the post for a custom post type. I have the custom post type to the following functions which I thought would be controlling this image (rpr_recipe is the custom post type):
//* Localize backstretch script
add_action( 'genesis_after', 'ambiance_set_background_image' );
function ambiance_set_background_image() {if ( is_singular( array ('post', 'page', 'rpr_recipe' ) ) ) {
$image = array( 'src' => has_post_thumbnail() ? genesis_get_image( array( 'format' => 'url' ) ) : '' );wp_localize_script( 'ambiance-backstretch-set', 'BackStretchImg', $image ); }
}
//* Hook entry background area
add_action( 'genesis_after_header', 'ambiance_entry_background' );
function ambiance_entry_background() {if ( is_singular( array ('post', 'page','rpr_recipe' ) && has_post_thumbnail() ) ) {
echo '<div class="entry-background"></div>';
}}
This generates the space above the recipe output, but no image is generated. Would any one have further suggestions of what I could do to generate the image?
Cheers,
Nick
http://syd.creativeplatoon.com/food-demo-three/recipe/seasoning-mix/January 28, 2015 at 10:20 am #138849David Chu
ParticipantHi,
That's an interesting idea, using Backstretch for that. I can give you a lead, but that's about it without being in there.When you define your Custom Post Type, you'll need to give it thumbnail (aka Featured Image) support. If you're using a CPT interface, check there, or have a look at the documentation, doing a find on "thumbnail".
Good luck,
Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
January 28, 2015 at 4:39 pm #138890duellingpixels
ParticipantHi David,
Thanks for your response.
Yes, the cpt has thumbnail support already. The images are displaying without any issues on the recipes archive page. It is just on the singular page that the feature will not display. This is why I am a bit lost on the cause of the problem.
Thanks
Nick
January 28, 2015 at 6:32 pm #138894David Chu
ParticipantYou're on the case, then! I've got a couple of last thoughts. Beyond a typo, which is possible in that fairly complex code, all those nested structures....
I wonder if "is_singular" may not be working in the context of your code, such as its location relative to the loop. Maybe test that specifically. A longshot.
Cheers, D
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
January 28, 2015 at 6:55 pm #138896duellingpixels
ParticipantHi David,
I worked it out, it looks like it is bug in the recipe plugin and basically a feature image does not show if the instructions field have not been created.
Thanks for offering your assistance!
Cheers,
Nick
January 28, 2015 at 9:38 pm #138916David Chu
ParticipantNick,
Good sleuthing! With your willingness to write code, you'll go far!I hadn't seen that recipe plugin. Here's some gossip for you.... I was working with Easy Recipe Plus the other day, and it's quite nice, but a funny thing about it is that it can be a bit of a resource hog.
If I were doing anything hardcore with recipes, I might just use straight Custom Post Types and template them myself. 🙂
Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.