Using WordPress ‘feed_links_extra_show_post_type_archive_feed’ PHP filter

The feed_links_extra_show_post_type_archive_feed WordPress PHP filter lets you control the display of the post type archive feed link.

Usage

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

Parameters

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

More information

See WordPress Developer Resources: feed_links_extra_show_post_type_archive_feed

Examples

Hide the post type archive feed link for all post types

This example prevents the post type archive feed link from being displayed for all post types.

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

Show the post type archive feed link only for ‘events’ post type

This example displays the post type archive feed link only for the ‘events’ post type.

add_filter('feed_links_extra_show_post_type_archive_feed', function($show) {
    if (is_post_type_archive('events')) {
        return true;
    }
    return false;
});

Hide the post type archive feed link for ‘products’ post type

This example hides the post type archive feed link for the ‘products’ post type.

add_filter('feed_links_extra_show_post_type_archive_feed', function($show) {
    if (is_post_type_archive('products')) {
        return false;
    }
    return $show;
});

Toggle post type archive feed link display based on user role

This example shows the post type archive feed link only for users with the ‘editor’ role.

add_filter('feed_links_extra_show_post_type_archive_feed', function($show) {
    if (current_user_can('editor')) {
        return true;
    }
    return false;
});

Display the post type archive feed link only on specific days

This example displays the post type archive feed link only on Mondays.

add_filter('feed_links_extra_show_post_type_archive_feed', function($show) {
    $current_day = date('N');
    if ($current_day == 1) {
        return true;
    }
    return false;
});

END