New Landing How can we help? Themeforest Theme Support Uplift How to Change 'Related Articles' Title below posts?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Posted in: Uplift
  • #289043
    mhote
    Member
    Post count: 394

    Hi, how we we change ‘Related Articles’? Couldn’t find this in theme files. Thank you

    #289071
    David Martin – Support
    Moderator
    Post count: 20834

    Please install and activate the supplied child theme, inside the child theme functions.php file paste the below in.

    You can then change the below “Related Articles” to your desired.

        /* POST RELATED ARTICLES
        ================================================== */
        if ( ! function_exists( 'sf_post_related_articles' ) ) {
            function sf_post_related_articles() {
    
                $related_articles_class = apply_filters( 'sf_post_related_articles_wrap_class', 'container' );
    			$related_articles_display_type = apply_filters( 'sf_related_articles_display_type', 'bold' );
    			$related_articles_excerpt_length = apply_filters( 'sf_related_articles_excerpt_length', 20 );
    			$related_articles_count = apply_filters( 'sf_related_posts_count', 4 );
    			$related_articles_item_class = apply_filters( 'sf_related_posts_item_class', 'col-sm-3' );
    			
    			$list_class = 'posts-type-'.$related_articles_display_type;
    
    			if ($related_articles_display_type == "bold") {
    				$list_class .= ' no-gutters';
    			} else {
    				$list_class .= ' row';
    			}
    
                global $post;
    
                $args       = array();
                $tags       = wp_get_post_tags( $post->ID );
                $categories = get_the_category( $post->ID );
                if ( ! empty( $tags ) ) {
                    $tag_ids = array();
                    foreach ( $tags as $individual_tag ) {
                        $tag_ids[] = $individual_tag->term_id;
                    }
                    $args = array(
                        'tag__in'             => $tag_ids,
                        'post__not_in'        => array( $post->ID ),
                        'posts_per_page'      => $related_articles_count, // Number of related posts to display.
                        'ignore_sticky_posts' => 1
                    );
                } else if ( ! empty( $categories ) ) {
                    $category_ids = array();
                    foreach ( $categories as $individual_category ) {
                        $category_ids[] = $individual_category->term_id;
                    }
    
                    $args = array(
                        'category__in'   => $category_ids,
                        'post__not_in'   => array( $post->ID ),
                        'posts_per_page' => $related_articles_count, // Number of related posts that will be shown.
                        'orderby'        => 'rand'
                    );
                }
    
                $related_posts_query = new WP_Query( $args );
                if ( $related_posts_query->have_posts() ) {
                    echo '<div class="related-wrap">';
                    echo '<div class="related-articles ' . $related_articles_class . '">';
                    echo '<div class="title-wrap"><h3 class="spb-heading"><span>' . __( "Related Articles", 'uplift' ) . '</span></h3></div>';
                    echo '<div class=" recent-posts '.$list_class.' clearfix">';
    
                    while ( $related_posts_query->have_posts() ) : $related_posts_query->the_post();
                        echo sf_get_recent_post_item( $post, $related_articles_display_type, $related_articles_excerpt_length, $related_articles_item_class );
                    endwhile;
    
                    echo '</div>';
                    echo '</div>';
                    echo '</div>';
                }
            }
        	add_action( 'sf_post_after_article', 'sf_post_related_articles', 10 );
    	}
    #289078
    mhote
    Member
    Post count: 394

    Perfect, thanks David

    #289104
    David Martin – Support
    Moderator
    Post count: 20834

    Happy to help!

    – David.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register