Using WordPress ‘feed_links_extra_show_category_feed’ PHP filter

The feed_links_extra_show_category_feed WordPress PHP filter allows you to control the display of the category feed link.

Usage

add_filter('feed_links_extra_show_category_feed', function($show) {
    // your custom code here
    return $show;
});

Parameters

  • $show (bool): Whether to display the category feed link. Default is true.

More information

See WordPress Developer Resources: feed_links_extra_show_category_feed

Examples

To hide the category feed link, simply return false.

add_filter('feed_links_extra_show_category_feed', function($show) {
    return false;
});

To show the category feed link only for specific categories, check the current category and decide whether to display it.

add_filter('feed_links_extra_show_category_feed', function($show) {
    $category = get_queried_object();

    // Allow feed link for category ID 5 and 10
    if (in_array($category->term_id, array(5, 10))) {
        return true;
    }

    return false;
});

Hide the category feed link if the category has no posts.

add_filter('feed_links_extra_show_category_feed', function($show) {
    $category = get_queried_object();

    if ($category->count === 0) {
        return false;
    }

    return $show;
});

Only show the category feed link to logged-in users.

add_filter('feed_links_extra_show_category_feed', function($show) {
    if (is_user_logged_in()) {
        return true;
    }

    return false;
});

Hide the category feed link on weekends (Saturday and Sunday).

add_filter('feed_links_extra_show_category_feed', function($show) {
    $current_day = date('w');

    // Hide on Saturday (6) and Sunday (0)
    if ($current_day == 6 || $current_day == 0) {
        return false;
    }

    return $show;
});