• Hi, i want to count the post title characters, someone knows where do i have to put the sentence so it would work correctly?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Example title: Hello World!

    <?php echo strlen(trim(get_the_title())); ?>

    Output:

    12

    Strlen: Determines the string length
    Trim: Removes unwanted characters
    get_the_title: Gets the title value

    And the “echo” just prints the output..

    Incase you wanted a break down.. ??

    Thread Starter issieparis

    (@issieparis)

    yeah, thats great, but where do i have to put the sentence, i dont get it clearly, do i have to put it in the style sheet, the index page, the post page???

    Where do you want to show the number?..

    I can’t tell you where to put it, if you don’t tell me where you want to see it.

    ??

    Thread Starter issieparis

    (@issieparis)

    actually i want to count them for something more complex, but for know i just want the count to work…

    i want to count the characters in the post title to make it a variable to make a background image porcentual to this lenght. In simple words, i want them to be aside without runing over each other.

    You can see it in https://www.visual.gi/blog&#8230; its the orange line i want to modify.

    But as i told, first step first, by now i just want to make the count works properly.

    <?php $yourvariable = strlen(trim(get_the_title())); ?>
    Thread Starter issieparis

    (@issieparis)

    thanks ill try to see if it works ??

    Thread Starter issieparis

    (@issieparis)

    it doesnt count them, i just get the sentence to be visible in the site

    not quite sure what you want to achieve – so my guess is that you want the orange line just to be to the right of the title (see my example picture).
    if so, try following change to the style.css:

    .post .title a {
    	color: #000000;
    background:#fff; padding:10px; margin-left:-10px;
    }

    what it does, is to put a white background behind the title that then covers the orange line. you probably also need to change the graphic for the orange line.

    if you want something else, forget my post ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘want to count characters’ is closed to new replies.