depends exactly where you are putting that code, and which thumbnail you are wanting
get_the_post_thumbnail( $reply_id, $size, $attr );
may well be what you want.
Otherwise come back with where the code is going.
I am trying to grab the $post_id from the parent
something like this?
function pym_print_featured_image_on_topic() {
if (has_post_thumbnail()) {
echo '<div class="pym-bbp-topic-thumbnail">';
echo get_the_post_thumbnail('post_parent', 'thumbnail' );
echo '</div>';
}
still no clearer on where this code is going, and which thumbnail you are after.. sorry I’d love to help but I’m still not understanding what you are trying to achieve.
Sorry,
I have a featured image/thumbnail attached to each forum topic.
I would like each post, in that topic, to call that featured image as well.
I am assuming that each topic is the parent of each post?
so I created this function in my functions.php file
add_action('bbp_template_before_post', 'pym_print_featured_image_on_topic()')
function pym_print_featured_image_on_topic() {
//get the post id of the parent
//$postimage = get_post( 'post_parent' );
if (has_post_thumbnail()) {
echo '<div class="pym-bbp-topic-thumbnail">';
echo get_the_post_thumbnail('<strong>post_parent</strong>', 'thumbnail' );
echo '</div>';
}
}
Which I am then calling in side of loop-single-topic.php
<?php do_action( ‘bbp_template_before_post’ );?>
Thanks for your help!
Malcolm
ok – that’s great – I think I now understand
loop-single-topic is probably not the right/only place
but within loop single topic, you can get the ID from bbp_topic_id() which will be itself, so no need to call post parent
Replies – that is posts in response to a topic, which is I think what you are after, are handled by loop-single-reply.php
There each reply has an id found by using bbp_reply_id, so you would use something like
$postimage = wp_get_post_parent_id( bbp_reply_id() );
in your code above