WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Convert out accented characters from the_title (5 posts)

  1. ADBL
    Member
    Posted 4 years ago #

    I'm using <?php the_title(); ?> to include external links based on pages title. This works great, except that on some sites, accented characters will break search results, e.g.:

    http://www.variety.com/search/siteall?q=amélie&x=0&y=0&s=date
    vs.
    http://www.variety.com/search/siteall?q=amelie&x=0&y=0&s=date

    Is there a way I could convert accented to corresponding "normal" characters from the_title?

    Like the word "amélie" would be returned as "amelie".

    Many thanks.

  2. threestyler
    Member
    Posted 4 years ago #

    WordPress has a function for this <?php remove_accents( $string ) ?>

  3. ADBL
    Member
    Posted 4 years ago #

    Thanks for your answer!

    How would I apply it to the_title in :

    More about <?php the_title(); ?>: <a href="http://www.google.com/images?q=%22<?php the_title(); ?>%22 films" target="_blank">Google Images</a>

    And how would I do strip accents from the second instance (within the url) and leave them in the first one "More about <?php the_title(); ?>".

    TIA.

  4. ADBL
    Member
    Posted 4 years ago #

    That would do:
    <?php remove_accents(the_title()) ; ?>

  5. ADBL
    Member
    Posted 4 years ago #

    <a href="http://www.site.com/search/siteall?q=<?php remove_accents(the_title()) ; ?>&x=0&y=0&s=date" target="_blank">Site</a>

    Doesn't seem to remove accents anymore here...

    I checked, it's the right template, same one that would work a couple of days ago.

    remove_accents(the_title()) does the same as the_title()

    Could that be a plugin conflicting? Something wrong in my syntax?

    TIA.

Topic Closed

This topic has been closed to new replies.

About this Topic