• Resolved snippet24

    (@snippet24)


    First context: I’m using custom fields (field type WYSIWYG Editor) to set the meta description of certain pages, for which I’m currently using this code:

    <meta name="description" content="<?php $descripcionschema0 = strip_tags(get_field(name_customfield)); $descripcionschema = str_replace('<br />', ', ', $descripcionschema0); echo preg_replace('/[^\p{L}\p{N}\s]/u', '', $descripcionschema); ?>">

    Now the problem is I noticed I’m getting unicode values for certain characters in the meta descriptions like double quotes. Example: “…text 8220 more text” , how can I replace all unicode values and or further improve this code?

    • This topic was modified 1 year, 11 months ago by snippet24.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter snippet24

    (@snippet24)

    Update: trying

    <meta name="description" content="<?php echo apply_filters( 'the_excerpt', get_field( 'fieldname' ));">

    See if this works:

    <meta name="description" content="<?php 
        $description_raw = get_field('name_customfield');
        $description_html = html_entity_decode($description_raw);
        $description_stripped = strip_tags($description_html);
        $description_encoded = htmlspecialchars($description_stripped, ENT_QUOTES, 'UTF-8');
        echo $description_encoded;
    ?>">
    
    Thread Starter snippet24

    (@snippet24)

    Thank you so much were quicker than me ?? In case it helps as well someone I’m posting my solution as well:

    <?php $descripcionschema = strip_tags(html_entity_decode(get_field(filed_name)),''); ?> 
                <meta name="description" content="<?php echo apply_filters( 'get_the_excerpt', $descripcionschema); ?>">

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help how to remove double quotes unicode values and other unicode values?’ is closed to new replies.