Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom View: Most Recent topics with Topic Featured Image

  • @malmac

    Participant

    Hello All,

    This is what I have so far:

    in my functions.php file:
    bbp_register_view( 'recent-with-topic-image', __( 'Recent With Topic Image' ), array(false ,'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 8 ), false );

    corresponding short code
    [bbp-single-view id="recent-with-topic-image"]

    What can I add to array to show the featured image from the topic that the post is in?

    Thanks, Malcolm

Viewing 6 replies - 1 through 6 (of 6 total)
  • @robkk

    Moderator

    If you want a specific view to have images, you would need to create a custom view template called either single-view-recent-with-topic-image.php or view-recent-with-topic-image.php and most of the code would be based on the single-view.php template in the extras folder in the bbPress plugin, you would have to make it custom enough to include the featured image code, and I guess however your users will be able to select a featured image during topic creation.

    @malmac

    Participant

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

    @robkk

    Moderator

    The shortcode that you posted seemed alright with the code you posted, so you had the right ID and everything, only thing I would possibly say is if those quotes don’t work use single quotes.

    '

    @malmac

    Participant

    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!

    @robkk

    Moderator

    Creating a new view template will help with the layout of how you want it. And yes you can still show that view with a shortcode.

    @malmac

    Participant

    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar