Function and usage of is_archived() in wordpress


Answers ( 1 )


    The is_archived() function in WordPress is a utility function used to check if a specific blog, identified by its ID, is archived. This function is particularly useful in a WordPress Multisite environment where there are multiple blogs or sites under a single WordPress installation. Here's a detailed explanation:

    Function Signature:

    is_archived( int $id ): string


    • $id (int, required): This parameter represents the unique identifier of the blog you want to check. Each blog in a WordPress Multisite network has a unique ID.

    Return Value:

    • The function returns a string. If the blog with the specified ID is archived, it returns a value indicating this status. If the blog is not archived, it returns a value that signifies that the blog is active.


    Here's a sample usage of the is_archived() function:

    // Sample usage of the is_archived() function
    $blog_id = 5; // Replace with the actual blog ID you want to check
    // Checking if the blog is archived
    $is_archived = is_archived($blog_id);
    if ($is_archived) {
        echo "Blog with ID " . $blog_id . " is archived.";
    } else {
        echo "Blog with ID " . $blog_id . " is not archived.";

    In this example:

    • We define a blog ID to check (here, 5 as an example).
    • We call is_archived() with this ID.
    • Based on the returned value, we output a message indicating whether the blog is archived or not.

    This function is particularly useful for network administrators in a WordPress Multisite environment to manage and keep track of the status of different blogs/sites in their network.

Leave an answer