• Is this possible. I’ve tried a few different ways of doing this, to no avail.

    Most recently I tried the following code:

    <?php echo $post->post_content; ?>

    This pulls the content of each post in the blog, but it takes out some of the formatting, such as paragraph and line break tags, so that my posts are one large block of text. Still, it pulls images and puts appropriately tagged text in bold or italics, so I know it’s not just stripping the markup from each post, in order to just pull the text.

    Is there a way to fix this so that paragraphs and line breaks show up? I’m sure I’ve seen the answer to this question in the Support somewhere, but for the life of me, I can’t find it now.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Why not use The_Loop?

    Thread Starter southboundhome

    (@southboundhome)

    I am. But using the_content(), even within The Loop, doesn’t work on a page that’s located outside of the folder that I have WP installed in.

    Right? It’s not working for me, at least. Am I missing something?

    You have to use the WordPress “header” at the top of the index page. Then you can call “the_loop”.

    Use:

    <?php require('./wordpressdirectory/wp-blog-header.php');?>

    At the top of the page you’re wishing to call the loop from. Then declare your “doctype” and what not.

    I’ve used this for the index of my website…but it’s been a while since I coded it. Should at least get you on the right track.

    Thread Starter southboundhome

    (@southboundhome)

    The header is included at the top of the index. Everything is inside the loop. The Posts’ titles, dates, excerpts, etc., etc. are all being pulled to my index page successfully.

    The only tag that is not pulling successfully/correctly is the_content(), and I was hoping that there was an alternative way to get the body of a post into a page outside of WP. Seems like there should be, but I can’t find information on it anywhere.

    I just tried using the_content on my site. It appeared to work properly.

    I’m not sure what your coding is on the page you are using…but I’ve just had success with the_content.

    The formatting wasn’t perfect, but I have a separate style sheet for that index page, so that was to be expected.

    Perhaps there’s an error in the way you’re calling the_content?

    Thread Starter southboundhome

    (@southboundhome)

    Perhaps. What was the exact code that you used?

    <?php the_content(); ?>

    It was nothing special.

    If you’re getting excerpts, then you’re clearly calling up the database and it’s spitting back entries of some kind.

    Thread Starter southboundhome

    (@southboundhome)

    That’s not working for me, for some reason. You’re right though, the excerpt works fine, as do the title and post date information, so it should be able to pull the entire content of the post.

    Can any mods explain the problem? Or point me in the right direction at least?

    somewhat works for me, but I had to specify some extra stuff. simple <?php require('wp-blog-header.php');?><?php the_content(); ?> wasnt working for me (not exactly sure why, but both 2.x and 1.5x were having the issue for me).
    This is what I’m using – works fine in WP2.x, 1.5x acted a bit weird (wouldnt display the pictures from the blog, unless I specified the category (which is what I do in this example, I specify the category (category id 3))).

    <?php require('wp-blog-header.php');?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( (in_category('3')) ) { ?>
    <div class="post">
    <div class="entry">
    <?php the_content(); ?>
    </div>
    </div>
    <?php } ?>
    <?php endwhile; else: ?>
    Sorry, no posts matched your criteria.
    <?php endif; ?>

    I know this is old but for anyone having the same problem with the formatting after you add the:

    <?php echo $post->post_content; ?>

    To your PHP page out side of WP…All you have to do is go in to the ADMIN section of WP > go to manage and then to your post > switch it to code view and add your <p></p> tags and what not to what you are looking to format.

    I think what the echo code does is simply pull the text that you entered. So, just add the proper HTML formatting tags and it will pull that too.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Pulling the_content() to a page outside of WP?’ is closed to new replies.