WordPress.org

Ready to get started?Download WordPress

Forums

Problem with Dynamic Meta Description and Keywords (1 post)

  1. B_Dark
    Member
    Posted 2 years ago #

    i follow this tutorial:
    META Descriptions:

    <meta name=”description” content=”
    
        <?php if (have_posts() && is_single() OR is_page()):while(have_posts()):the_post();
    
        $out_excerpt = str_replace(array(“\r\n”, “\r”, “\n”), “”, get_the_excerpt());
    
        echo apply_filters(‘the_excerpt’, $out_excerpt);
    
        endwhile;
    
        elseif(is_category() OR is_tag()):
    
        if(is_category()):
    
        echo “Posts related to Category:
    
        “.ucfirst(single_cat_title(“”, FALSE));
    
        elseif(is_tag()):
    
        echo “Posts related to Tag:
    
        “.ucfirst(single_tag_title(“”, FALSE));
    
        endif;
    
        else: ?>
    
        ADD HERE YOUR DEFAULT DESCRIPTION
    
        <?php endif; ?>” />

    META Keywords:

    <meta name=”keywords” content=”
    
        <?php
    
        $tags = get_tags(array(‘orderby’ => ‘count’, ‘order’ => ‘DESC’));
    
        $xt = 1;
    
        foreach ($tags as $tag) {
    
        if ($xt <= 10) {
    
        echo $tag->name.”, “;
    
        }
    
        $xt++;
    
        }
    
        ?>ADD, HERE, YOUR, STATIC, KEYWORDS” />

    open graph description:

    <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" />

    i have the same problem, if i have in my "excerpt description" any word with special characters like "",'',«»
    example: hello "dog"
    when read the expert meta facebook the show only "Hello"(stop the description before the 1st special character) how can i fix that?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags