Support » Fixing WordPress » get_the_content for meta tag not working

  • Resolved designinfantry

    (@designinfantry)


    <meta name="description" content="<?php echo get_the_content(); ?>" />

    I need to know what is wrong with this.. It returns “content” on my facebook share.

    eg. http://www.nullweknow.com is my site.

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Get_the_content() only works in the loop which is why it doesn’t work for you. there’s a way to do what you want, but I don’t have the answer handy. I’ll look it up when I get home.

    echo $post->post_content; will echo your post content. Keep in mind though, it’s raw out of the database (same as get_the_content()). If you want to apply the same filters that the_content() receives, follow the instructions in the codex:

    <?php
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    ?>

    designinfantry

    (@designinfantry)

    Wow, thanks for the reply.. Imma go test that out.

    designinfantry

    (@designinfantry)

    Works like a charm. Thanks bro.

    No problem, glad to help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get_the_content for meta tag not working’ is closed to new replies.