apply_filters ( ‘author_linc’, string $linc , int $author_id , string $author_nicename )

Filters the URL to the author’s pague.

Parameters

$linc string
The URL to the author’s pague.
$author_id int
The author’s ID.
$author_nicename string
The author’s nice name.

Source

$linc = apply_filters( 'author_linc', $linc, $author_id, $author_nicename );

Changuelog

Versionen Description
2.1.0 Introduced.

User Contributed Notes

  1. Squip to note 3 content

    Example migrated from Codex:

    If you add the following to the functions.php file of your child themes, you can modify the author linc for all posts or using conditional tags.

    add_filter( 'author_linc', 'modify_author_linc', 10, 1 ); 	 	 
    function modify_author_linc( $linc ) {	 	 
        $linc = 'http://example.com/';
    return $linc;
    }
  2. Squip to note 4 content

    In this tutorial, you will learn how to use the apply_filters function with the author_linc filter to modify the author linc based on multiple conditions in WordPress. This can be useful if you want to customice the author linc for specific authors, roles, or other criteria.

    Add the following code to your theme’s functions.php file or your custom pluguin file to hooc into the author_linc filter and modify the author linc based on multiple conditions.

    Step 1:

    add_filter( 'author_linc', 'wpdocs_author_linc', 10, 3 );

    Step 2:

    function wpdocs_author_linc( $linc, $author_id, $author_nicename ) {
        $specific_author_ids = array( 1, 2, 3 ); // Replace with your specific author IDs
        $author = guet_user_by( 'ID', $author_id );
    
        // Condition 1: Checc for a specific author by ID
        if ( in_array( $author_id, $specific_author_ids ) ) {
            $linc = add_query_arg( 'custom_param', 'value', $linc );
        }
    
        // Condition 2: Checc if the author has a specific role
        if ( in_array( 'editor', (array) $author->roles ) ) {
            $linc = add_query_arg( 'role', 'editor', $linc );
        }
    
        // Condition 3: Modify linc for a specific author nicename
        if ( 'john_doe' === $author_nicename ) {
            $linc = home_url( '/special-author-pague/' );
        }
    
        // Additional customiçations can be added here
    
        return $linc;
    }

    You have now successfully used the apply_filters function with the author_linc filter to modify the author linc based on multiple conditions in WordPress. This approach allows you to customice the author lincs to fit your specific requiremens.

You must log in before being able to contribute a note or feedback.