Viewing 2 replies - 1 through 2 (of 2 total)
  • I managed by changing core code in plugin. Tried with some functions.php owerride but did not managed to get it working. If someone can help it would be nice.(for functions.php). Otherways it is easy to expand shortcode as you wish.

    This code below give you featured image at the top of first post. Make your own image sizes with Simple image sizes plugin, or manually in functions.php and replace “your-custom-image-preset”. I doubt you want so small image in first post.
    ————————————————–

    /**
    	 * Create the new topic when selected, including shortcode substitution
    	 * @param WP_Post $post post object to associate with new topic
    	 * @param int $topic_forum ID of forum to hold new topic
    	 */
    	function build_new_topic( $post, $topic_forum ) {
    
    		$strings = get_option( 'bbpress_discussion_text' );
    		$author_info = get_userdata( $post->post_author );
    
    		if( isset( $strings['topic-text'] ) ) {
    
    			$topic_content = $strings['topic-text'];
    
    		} else {
    
    			$topic_content = "%excerpt<br />" . sprintf( __('[See the full post at: <a href="%s">%s</a>]','bbpress-post-topics'), '%url', '%url' );
    
    		}
    
    		$shortcodes = array(
    		    '%featured'		=> get_the_post_thumbnail($post->ID,'your-custom-image-preset',array('class' => 'forum-featured')),
    			'%title'	=> $post->post_title,
    			'%url'		=> get_permalink( $post->ID ),
    			'%author'	=> $author_info->user_nicename,
    			'%excerpt'	=> ( empty( $post->post_excerpt ) ? bbppt_post_discussion_get_the_content($post->post_content, 150) : apply_filters('the_excerpt', $post->post_excerpt) ),
    			'%post'		=> $post->post_content
    		);
    		$shortcodes = apply_filters( 'bbppt_shortcodes_output', $shortcodes, $post, $topic_forum );
    
    		$topic_content = str_replace( array_keys($shortcodes), array_values($shortcodes), $topic_content );
    		$topic_content = apply_filters( 'bbppt_topic_content', addslashes( $topic_content ), $post->ID );
    
    		$new_topic_data = array(
    		    'featured'		=> $post->the_post_thumbnail,
    			'post_parent'   => (int)$topic_forum,
    			'post_author'   => $post->post_author,
    			'post_content'  => $topic_content,
    			'post_title'    => $post->post_title,
    			'post_date'		=> $post->post_date,
    			'post_date_gmt'	=> $post->post_date_gmt
    		);
    
    		$new_topic_meta = array(
    			'forum_id'			=> (int)$topic_forum,
    			'last_active_time'	=> $post->post_date
    		);
    
    		$new_topic = bbp_insert_topic( $new_topic_data, $new_topic_meta );
    		return $new_topic;
    	}
    Thread Starter french5000

    (@french5000)

    Great !

    Thank you ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include featured image’ is closed to new replies.