• Starting off, here is a random example post of what I’m working with on my website. Link Here.

    I know it’s possible to entirely remove the “Related Posts” area on a post.

    I want it to be there, but for aesthetic purposes I would like to change how many appear in that box. I think it’s 5 currently.

    I would like it to display maybe 3 or 4 because that 5th one creates this empty gap that pushes my text too far away from the image.

    Help would be appreciated. If this question has already been answered, please redirect me to it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Can you tell me how to remove the related posts? I can’t find it at all. As for your problem, I’d try to find the PHP file that handles the related post and change the amount of articles it calls.

    Theme Author Rigorous Themes

    (@wpgaint)

    Hi Chase,
    To change any layout of theme or customize it better option is to create child theme and customize it from child theme.

    You have not create child theme in your site. If you wish to create child theme you can find online tutorials.

    If you use child theme please use following function in functions.php of your child theme:

    function profitmag_related_post( $post_id ) {
            $categories = get_the_category( $post_id );
            if( $categories ) {
                $category_ids = array();
                foreach( $categories as $category ) {
                    $category_ids[] = $category->term_id;
                }
                $args = array(
                        'category__in' => $category_ids,
                        'post__not_in' => array( $post_id ),
                        'posts_per_page' => 5,
                        );
                $related_query = new WP_Query( $args );
                if( $related_query->have_posts() ) {
                    echo '<ul>';
                    while( $related_query->have_posts()){
                        $related_query->the_post();
        ?>
                        <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> 
    
        <?php
                    }
                    echo '</ul>';
        ?>
        <?php
                }else {
        ?>
                    <ul><li><?php _e( 'No related post.', 'profitmag-pro'); ?></li></ul>
        <?php
                }
              wp_reset_postdata();
            }
        }

    then change 'posts_per_page' => 5, to your required number.

    If you wish to change core file of main theme you can change it at line 556 of:
    inc/profitmag-functions.php

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need Help Changing The Number Of Related Posts’ is closed to new replies.