WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get_the_content for meta tag not working (6 posts)

  1. designinfantry
    Member
    Posted 4 years ago #

    <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.

  2. Taylor Dewey
    Member
    Posted 4 years ago #

    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.

  3. Taylor Dewey
    Member
    Posted 4 years ago #

    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);
    ?>
  4. designinfantry
    Member
    Posted 4 years ago #

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

  5. designinfantry
    Member
    Posted 4 years ago #

    Works like a charm. Thanks bro.

  6. Taylor Dewey
    Member
    Posted 4 years ago #

    No problem, glad to help.

Topic Closed

This topic has been closed to new replies.

About this Topic