Function and usage of feed_links_extra() in wordpress


Answers ( 1 )


    The feed_links_extra() function in WordPress is used to display links to extra feeds, such as category feeds. Here's a detailed explanation and sample usage:


    • Name: feed_links_extra
    • Purpose: To display links to additional RSS feeds beyond the main site feed. These can include category-specific, tag-specific, or custom taxonomy feeds.


    • $args (array, optional): This parameter allows you to specify additional arguments for the feed links. It's an associative array.
      • Default Value: array(), which means no additional arguments are provided by default.


    To use feed_links_extra(), you can either call it without any parameters or pass an array of arguments to customize its behavior. The function does not return a value; it directly outputs the feed links.

    Default Usage


    This will output extra feed links with default settings.

    With Arguments

    You can pass an array of arguments to customize the output. For instance:

    $args = array(
        'category' => get_category_link( $category_id ), // Replace $category_id with the actual category ID
        // ... Other arguments can go here
    feed_links_extra( $args );

    This example will display a feed link for a specific category.


    • This function is typically used in the header of a WordPress theme to provide users and feed readers with direct access to various RSS feeds.
    • The function should be called within the HTML <head> section for optimal utility.
    • Customizing this function requires a basic understanding of PHP and the WordPress template system.

    Sample Scenario

    Suppose you have a news website and want to provide separate RSS feeds for each news category. You could add feed_links_extra() to your theme's header.php file, customized with category-specific arguments, to automatically output feed links for all your news categories.

Leave an answer