Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter td2025

    (@td2025)

    Sorry, I didn’t copy the comment opening tag… use this one falta “/” inicial

    /**
    **CHANGE DEFAULT AUTHOR DISPLAY TO CO_AUTHOR BY J.L.
    */

    add_filter('the_author', function($author) {
    // Check if Co-Authors Plus is active
    if (function_exists('get_coauthors')) {
    $coauthors = get_coauthors();

    if (!empty($coauthors)) {
    // Gets the visible names of the authors
    $names = array_map(function($a) {
    return esc_html($a->display_name);
    }, $coauthors);

    // Returns all authors, separated by commas
    return implode(', ', $names);
    }
    }

    / If not active or there are no co-authors, returns the original author
    return $author;
    });
    • This reply was modified 10 months, 2 weeks ago by td2025.
    • This reply was modified 10 months, 2 weeks ago by td2025.
    Thread Starter td2025

    (@td2025)

    Hello again

    For anyone who might need it:

    After trying various options, what worked best for me was this:

    What it does is replace the default author information with co-author. For convenience, check that the plugin is active; if it isn’t, it won’t apply changes to avoid errors.

    Just insert the code into a child theme in functions.php (avoid editing the parent theme). I think it should work on any theme, not just Astra.

    (Hope this helps)

    **
    *CHANGE DEFAULT AUTHOR DISPLAY TO CO_AUTHOR BY J.L.
    */

    add_filter('the_author', function($author) {
    // Check if Co-Authors Plus is active
    if (function_exists('get_coauthors')) {
    $coauthors = get_coauthors();

    if (!empty($coauthors)) {
    // Gets the visible names of the authors
    $names = array_map(function($a) {
    return esc_html($a->display_name);
    }, $coauthors);

    // Returns all authors, separated by commas
    return implode(', ', $names);
    }
    }

    // If not active or there are no co-authors, returns the original author
    return $author;
    });

    Thread Starter td2025

    (@td2025)


    Thank you for answering my question.

    I’ve managed to get it to display, but it’s not in the expected place. It doesn’t replace the ASTRA author meta. It displays it below the post text and not in place of the Astra author meta, which is where I expected it to display. Is there a way to replace the Astra author meta with co-author? Another problem is that it inserts it in the middle of the extract!

    https://prnt.sc/LK7rXm5xm8R2

    • This reply was modified 10 months, 2 weeks ago by td2025.
Viewing 3 replies - 1 through 3 (of 3 total)