Support » Fixing WordPress » Losing links when echoing post content?

  • Resolved patrickowtf

    (@patrickowtf)


    hey all

    i’m inserting some links within my post, but when I publish the post, they are gone. They don’t appear in the post at all. Not in the source or anything. I’m not sure why this is happening. I think it might have something to do with the way i’m echoing out my post content? But i’m not sure.

    I have the post with the links in it, and in my customPost template that I made i’m doing this…

    $theID = get_the_ID();
         $content_post = get_post($theID);
         $content = $content_post->post_content;

    and then later on in my php, in the proper DIV, i’m echoing

    <? echo $content; ?>

    does anyone have any idea as to why I might be losing my links?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try adding this filter in your code:

    $content = apply_filters('the_content', $content);

    So, final code will look like this:

    $theID = get_the_ID();
         $content_post = get_post($theID);
         $content = $content_post->post_content;
         $content = apply_filters('the_content', $content);

    Thread Starter patrickowtf

    (@patrickowtf)

    thanks josh. but i just figured it out without that.

    changed it from
    $content = $content_post ->post_content
    to
    $content = get_the_content();
    which apparently keeps the links in tact.

    thanks!

    You bet!!

    Super glad you got it worked out!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Losing links when echoing post content?’ is closed to new replies.