WordPress.org

Forums

Hueman
[resolved] How to remove or disable Related Posts function (9 posts)

  1. MicCheckOne
    Member
    Posted 1 year ago #

    Hello all.

    How do I completely remove/disable the Related Posts function from the Hueman theme? I tried to do this via my child theme stylesheet, like so:

    .related-posts { display: none; }

    This removed the actual links/thumbnails to related posts, but the related posts heading ("You May Also Like...") still appears. You can see the problem here.

    I'm guessing that I need to modify some code in the functions.php file, but I'm clueless about PHP. How do I remove, or disable, or comment-out, this function?

    /*  Related posts
    /* ------------------------------------ */
    if ( ! function_exists( 'alx_related_posts' ) ) {
    
    	function alx_related_posts() {
    		wp_reset_postdata();
    		global $post;
    
    		// Define shared post arguments
    		$args = array(
    			'no_found_rows'				=> true,
    			'update_post_meta_cache'	=> false,
    			'update_post_term_cache'	=> false,
    			'ignore_sticky_posts'		=> 1,
    			'orderby'					=> 'rand',
    			'post__not_in'				=> array($post->ID),
    			'posts_per_page'			=> 3
    		);
    		// Related by categories
    		if ( ot_get_option('related-posts') == 'categories' ) {
    
    			$cats = get_post_meta($post->ID, 'related-cat', true);
    
    			if ( !$cats ) {
    				$cats = wp_get_post_categories($post->ID, array('fields'=>'ids'));
    				$args['category__in'] = $cats;
    			} else {
    				$args['cat'] = $cats;
    			}
    		}
    		// Related by tags
    		if ( ot_get_option('related-posts') == 'tags' ) {
    
    			$tags = get_post_meta($post->ID, 'related-tag', true);
    
    			if ( !$tags ) {
    				$tags = wp_get_post_tags($post->ID, array('fields'=>'ids'));
    				$args['tag__in'] = $tags;
    			} else {
    				$args['tag_slug__in'] = explode(',', $tags);
    			}
    			if ( !$tags ) { $break = true; }
    		}
    
    		$query = !isset($break)?new WP_Query($args):new WP_Query;
    		return $query;
    	}
    
    }

    Thank you in advance!

  2. Alexander Agnarson
    Member
    Theme Author

    Posted 1 year ago #

    Hi!

    Theme Options > Blog > Single - Related Posts > Off

    And there you go!

  3. MicCheckOne
    Member
    Posted 1 year ago #

    Wow, I was making that way too complicated.

    Thank you, Alexander! This theme is awesome. You spoil us.

  4. rsspanic
    Member
    Posted 1 year ago #

    Hi, same issue but I don't see this option at all under blog posts… if I go to customize theme (PS I'm using WordPress 3.9.1 and Focus 1.0.8 made into a child theme) and look under “blog settings”, I see only two settings- “select category” and “number of posts per page”.

    where is this “Theme Options > Blog > Single – Related Posts > Off” supposed to be? I also looked under Settings > reading. Thanks

  5. frasermarlow
    Member
    Posted 8 months ago #

    It's under the generic WordPress menu 'Appearance' in the admin console.
    Then look for 'Theme Options'
    Then look for the 'tab' called 'Blog'
    Then scroll down and it's second option from the end called "Single — Related Posts"... "Shows randomized related articles below the post"

  6. mdivk
    Member
    Posted 2 months ago #

    I am having the same need: I am using profitmag, all the above solutions are not applied to this theme, I wonder there is the backend code for generating "related post" section in the page, I checked page.php and there is no "related post"

  7. bdbrown
    Member
    Posted 2 months ago #

    Hi mdivk. This thread is six months old and has been marked as Resolved. Please start a new topic here: https://wordpress.org/support/theme/hueman#postform. You can reference this post if needed.Thank you.

  8. WPyogi
    Forum Moderator
    Posted 2 months ago #

    @mdivk - you are not using this theme - you need to post on the forum for the theme you are using - here:

    https://wordpress.org/support/theme/profitmag#postform

  9. bdbrown
    Member
    Posted 2 months ago #

    @WPyogi. Missed that; thanks.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic