• Resolved microcoder

    (@microcoder)


    Hello,

    I have some post titles and filter values with the “&” symbol. All values are showing “&” instead of “&”.

    Does anyone have a fix for this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter microcoder

    (@microcoder)

    Update:
    I realized I could run the post titles through the _.unescape() function (edit the template). Then the titles will be displayed correctly.

    Now I just need to figure out how I can run the unescaping for the filter values.

    Plugin Contributor digamberpradhan

    (@digamberpradhan)

    Hi @microcoder ,

    Can you please specify what and where you’re using this ?
    I’ve tried this on both posts and page and the & are rendering properly for me.

    Thread Starter microcoder

    (@microcoder)

    Thanks for the response @digamberpradhan ,

    I did a fresh install with the standard theme to see if I got the same problem. I inserted a string “Foo & foo” into $formatted_data in the hook cm_typesense_data_before_entry and it rendered properly.

    I did some more investigation and found out that when I’m using get_the_terms() or get_the_title() the returning string is encoded. 

    Because of that, I tried to run the wp_specialchars_decode() function on my resulting values, like:

    $formatted_data['custom_value'] = wp_specialchars_decode(get_the_title($d));

    and then it works (proper rendering). Yay!

    Thanks for helping me out.

    Thread Starter microcoder

    (@microcoder)

    Due to my previous reply I checked how this is handled in the plugin and found this:

    /includes/Main/TypesenseAPI.php:167

    $category_names[] = html_entity_decode( $category->name );

    That confirms my previous reply and is the reason why it renders properly for the default category data ($formatted_data[‘category’]).

    Case closed.

    Plugin Contributor digamberpradhan

    (@digamberpradhan)

    Glad to hear you were able to figure things out.
    Cheers.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘“&” are displayed as “&”’ is closed to new replies.