• Resolved jasrop

    (@jasrop)


    Hello,

    I am trying to figure out how to limit the author description that appears in the author box at the bottom of every page.

    The code that appears in my single.php template is:
    <?php the_author_description(); ?>

    Please let me know how to modify this code to use a character limit or word count limit.

    Thanks in advance,
    Jason

Viewing 4 replies - 1 through 4 (of 4 total)
  • First, you should create a child theme so that your theme is update safe. Then after copying over single.php to your child theme, change that line to:
    <?php echo substr(get_the_author_meta('description'),0,100); ?>

    And change the 100 to however many characters you want to display.

    FYI: the_author_description() is deprecated, so use get_the_author_meta() instead.

    Cheers.

    There may be a better way through wordpress but just using php you could do something like:

    `<?php $auth_descrip = the_author_description();

    echo substr($auth_descrip, 0, 25); // the 25 will return the string up until that character limit.
    ?>

    Thread Starter jasrop

    (@jasrop)

    Thanks for the responses. I made the change and it worked fine.

    Glad it worked. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add word count or character limit to author description’ is closed to new replies.