Forums

Counting the # of char in the_title() (2 posts)

  1. sorkc
    Member
    Posted 1 year ago #

    Hi,

    I want to count the number of Characters in the title of each post on my archives page.

    This is what i have come up with, but i cannot make it work.

    It seems like "the_title()" is not a variable... Is this true?

    <?php
    $title_count = strlen(the_title());
    if ($title_count < 20 ) {
    	echo "TRUE ", $title_count;
    } else {
    	echo "FALSE ", $title_count;
    }
    ?>

    Is there anyway i can do this?

    best,

    soren

  2. elfin
    Moderator
    Posted 1 year ago #

    try this instead:
    $title_count = strlen(the_title('', '', false));
    the third parameter is usually true, which echo's the title.

Topic Closed

This topic has been closed to new replies.

About this Topic