MalMac (@malmac)

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

  • MalMac
    Participant

    @malmac

    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


    MalMac
    Participant

    @malmac

    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>';
    		}

    MalMac
    Participant

    @malmac

    Continuing on….

    In my themes function.php file I have the following which creates my thumbnail:

    	// /bbpress/templates/default/content-single-forum
    	add_action('bbp_template_before_single_forum', 'pym_print_featured_image_single_forum', 11);
    	add_action('bbp_template_before_single_forum', 'pym_print_forum_description', 12);
    	
    	function pym_print_featured_image_single_forum() {
    		if (has_post_thumbnail()) {
    			echo '<div class="pym-bbp-topic-thumbnail">';
    			echo get_the_post_thumbnail(null, 'thumbnail' );
    			echo '</div>';
    		}
    	}

    I have been calling this elsewhere in my template using ”

    
     <?php do_action( 'bbp_template_before_single_forum' ); ?>

    I am now trying to edit content-single-forum.php to call this thumbnail using the following:

    <?php bbp_get_template_part( 'loop', 'topics' ); ?>

    How do I go about getting the thumbnail to be called in the loop?

    Thanks, Malcolm


    MalMac
    Participant

    @malmac

    Apologies for being unclear,

    The shortcode I posted worked, just wondering if I create a new view template if I will be able to call it in a shortcode?

    Thanks!


    MalMac
    Participant

    @malmac

    Thats a great help, Thanks! Would it be possible to call this new view in a shortcode?

Viewing 5 replies - 1 through 5 (of 5 total)