Avada Forums Community Forum Portfolio Related Projects Reply To: Portfolio Related Projects

dagovehoel
Participant
Post count: 1

I solved it by adding this to the child-theme’s function.php:

function avada_render_related_posts( $post_type = 'post' ) {
	// Set the needed variables according to post type.
	if ( 'post' === $post_type ) {
		$theme_option_name = 'related_posts';
		$main_heading      = esc_html__( 'Related Posts', 'Avada' );
	} elseif ( 'avada_portfolio' === $post_type ) {
		$theme_option_name = 'portfolio_related_posts';
		$main_heading      = esc_html__( 'YOUR CUSTOM TITLE GOES HERE', 'Avada' );
	} elseif ( 'avada_faq' === $post_type ) {
		$theme_option_name = 'faq_related_posts';
		$main_heading      = esc_html__( 'Related Faqs', 'Avada' );
	}
	// Check if related posts should be shown.
	if ( isset( $theme_option_name ) && ( 'yes' === fusion_get_option( $theme_option_name, 'related_posts', get_the_ID() ) || '1' == fusion_get_option( $theme_option_name, 'related_posts', get_the_ID() ) ) ) {
		$number_related_posts = Avada()->settings->get( 'number_related_posts' );
		$number_related_posts = ( '0' == $number_related_posts ) ? '-1' : $number_related_posts;
		if ( 'post' === $post_type ) {
			$related_posts = fusion_get_related_posts( get_the_ID(), $number_related_posts );
		} else {
			$related_posts = fusion_get_custom_posttype_related_posts( get_the_ID(), $number_related_posts, $post_type );
		}
		// If there are related posts, display them.
		if ( isset( $related_posts ) && $related_posts->have_posts() ) {
			include wp_normalize_path( locate_template( 'templates/related-posts.php' ) );
		}
	}
}

It’s originally from the file avada-functions.php within the includes directory of the theme.