How to exclude a post from the Related Posts block

How to disable a specific post from showing in the Kadence Theme Related Posts block

How to exclude a post from the Related Posts block

To disable a specific post from showing in the related posts block at the end of each post in WordPress with the Kadence theme, you can follow these steps:

  1. Identify the Post: First, you need to identify the specific post that you want to exclude from the related content block.
  2. Use Plugins or Extensions: WordPress has plugins that allow you to control the visibility of specific posts in the related content block. You can install and use one of these plugins.
  3. Modify the Theme Settings: In the Kadence theme, you can go to Appearance > Customize > Theme Settings > Blog: Related Posts to control the related content.
  4. Use Code Snippets: If you’re comfortable with coding, you can add a code snippet to your theme’s functions.php file. Please note that this method should be used with caution as it involves modifying the theme’s code.

Remember, always backup your site before making any changes to the theme’s code. If you’re not comfortable with coding, it’s recommended to use a plugin or seek help from a professional.

How to exclude a post from the related posts section using the Code Snippets plugin

You can use the Code Snippets plugin to add a custom function to your WordPress site. Here’s a simple example of how you might exclude a specific post from the related posts section. This code would go into a new snippet in the Code Snippets plugin:

PHP Snippet

function exclude_specific_post_from_related( $args ) {
    // Replace 123 with the ID of the post to exclude
    $post_to_exclude = '123';

    if ( isset( $args['post__not_in'] ) ) {
        $args['post__not_in'][] = $post_to_exclude;
    } else {
        $args['post__not_in'] = array( $post_to_exclude );
    }

    return $args;
}
add_filter( 'kadence_related_posts_args', 'exclude_specific_post_from_related' );

In this code, replace 123 with the ID of the post you want to exclude. This function modifies the query arguments for the related posts, adding the specified post to the ‘post__not_in’ parameter, which excludes it from the query.

To identify the post ID on your site, open the post on your site’s backend and look for the number within the post’s URL on your content editor. E.g., https://yoursite.com/wp-admin/post.php?post=9217&action=edit. In this case, 9217 is the post ID.

Please note that this is a general example and might not work depending on your specific setup. Always back up your site before making changes, and consider consulting with a professional if you’re unsure.

To add the code to your site using code snippets, create a new snippet>add code> change code type to PHP> set location to sitewide footer > save.

How to exclude a post from the Related Posts block

How to exclude multiple posts from the related posts section

How to exclude two posts from the related posts section

If you want to exclude two posts from the related posts section, you can modify the code snippet to include the IDs of both posts. Here’s how you can do it:

PHP Snippet

function exclude_specific_posts_from_related( $args ) {
    // Replace 123 and 456 with the IDs of the posts to exclude
    $posts_to_exclude = array('123', '456');

    if ( isset( $args['post__not_in'] ) ) {
        $args['post__not_in'] = array_merge( $args['post__not_in'], $posts_to_exclude );
    } else {
        $args['post__not_in'] = $posts_to_exclude;
    }

    return $args;
}
add_filter( 'kadence_related_posts_args', 'exclude_specific_posts_from_related' );

In this code, replace 123 and 456 with the IDs of the posts you want to exclude. This function modifies the query arguments for the related posts, adding the specified posts to the ‘post__not_in’ parameter, which excludes them from the query.

How to exclude three posts from the related posts section

If you want to exclude three posts from the related posts section, you can modify the code snippet to include the IDs of all three posts. Here’s how you can do it:

PHP Snippet

function exclude_specific_posts_from_related( $args ) {
    // Replace 123, 456, and 789 with the IDs of the posts to exclude
    $posts_to_exclude = array('123', '456', '789');

    if ( isset( $args['post__not_in'] ) ) {
        $args['post__not_in'] = array_merge( $args['post__not_in'], $posts_to_exclude );
    } else {
        $args['post__not_in'] = $posts_to_exclude;
    }

    return $args;
}
add_filter( 'kadence_related_posts_args', 'exclude_specific_posts_from_related' );

In this code, replace 123, 456, and 789 with the IDs of the posts you want to exclude. This function modifies the query arguments for the related posts, adding the specified posts to the ‘post__not_in’ parameter, which excludes them from the query.

Disclosure: We may earn commission for purchases that are made by visitors on this site at no additional cost on your end. All information is for educational purposes and is not intended for financial advice. Read our affiliate disclosure.

Share this:

Similar Posts

  • E-commerce Sales Funnel: The Ultimate Guide to Drive Conversions and Sales

    E-commerce Sales Funnel : The Ultimate Guide to Drive Conversions and Sales Master the art of e-commerce sales funnels and transform your online business with proven strategies that drive conversions. This comprehensive guide reveals how to build, optimize, and scale sales funnels that convert visitors into loyal customers, backed by the latest industry statistics and…

  • Website Localization: Ultimate Guide for Global Success

    Website Localization: Ultimate Guide for Global Success Unlock international markets, boost conversions, and create meaningful connections with global audiences through strategic website localization. Table of Contents Introduction to Website Localization Benefits and ROI of Website Localization Key Website Localization Statistics Step-by-Step Website Localization Guide Website Localization Technologies and Tools Website Localization Costs and ROI Analysis…

  • 6 Best church donation plugins and church giving apps

    Are you looking for the best WordPress church donation plugins and church fundraising apps? In this article, I will explain some of the best fundraiser and donation plugins for churches and examine the features of each. What are the best church donation plugins and church giving apps? GiveWP GiveWP is a popular church donation plugin…

  • Kadence AI Review: Unveiling the Power of This SEO-Friendly Tool

    Kadence AI is a revolutionary feature that has transformed the process of creating and customizing websites using the Kadence Theme for WordPress. The AI-powered web creation process offers several innovative features that streamline website development and design. One of the standout features of Kadence AI is its “AI-Powered Inline Content,” which empowers users to improve…

  • Fastest WordPress themes: Best free lightweight themes

    The fastest WordPress themes in the market today include the following: Are you looking for the best free lightweight WordPress themes? Look no further! We have compiled a list of the top options available. Performance test of the fastest WordPress themes I created a simple WordPress website using each theme on a Vultr basic cloud…

  • How to add H1 tag in Kadence theme

    Are using the Kadence theme and are you getting an H1 tag error when you run an SEO analysis on your website? This error simply indicates that you have not added an H1 tag in Kadence theme. In this article, you will learn how to add H1 tag in Kadence theme. Search engines use the…

Leave a Reply

Your email address will not be published. Required fields are marked *