• Resolved mactoph

    (@mactoph)


    I think the way that I need to do this is to create a file that would write the title and excerpt of a post to a file that I could then include from another page, but I’ve tried a couple of ways to do that and am not having any luck?!
    I want just the title and excerpt without any of the surrounding template-
    I came up with this code that I think is right:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <h2><?php the_title(); ?></h2><br />
    <?php _e("Posted on "); ?><?php the_time('l j F Y',display); ?>

    <?php the_excerpt(); ?>

    <?php endwhile; else: ?><br />
    <?php _e('Sorry, no posts matched your criteria.'); ?><br />
    <?php endif; ?>

    but I’m not sure where to put it?- any help or better way of doing this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • It doesn’t matter where you put The Loop. What does matter is that A. the file you’re putting it in is a PHP file, and B. You’re including the wp-blog-header.php file at some point before it, like so:

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

    Just make sure the path to it is correct.

    Thread Starter mactoph

    (@mactoph)

    Thanks!!

    The way you want to go sounds a bit complicated: create a file that would have the title and excerpt, then include the file into another file…
    Why not pu the Loop directly into the “final” file?
    See also my (unfinished) tutorial about displaying WP in another webpage.

    Moshu! THANK YOU! Using your tutorial, and a few suggestions/advice from a couple of others here at the forum, my blog is now doing EXACTLY what I want it to do.

    I write in the blog /which is in it’s own folder/ and an excerpt shows up on my main root index. THANK you for the step by step (with pictures!) instructions. It was so helpful to see exactly what code I was suppose to be grabbing.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display Title and Excerpt on a page outside of WordPress’ is closed to new replies.