Showing post excepts on non wordpress part of site (3 posts)

  1. iq2010
    Posted 5 years ago #

    So my website was not built using wordpress, but I'm trying to integrate the wordpress part of it into my main page. Is there a way I could show the 3 most recent posts on my main page using php?

  2. DigitalSquid
    Posted 5 years ago #

    You just need to call the WordPress header so you can use it's functions and then make a loop to show the posts.

    Something like this should work:

    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-blog-header.php' );
    if (have_posts()) : while (have_posts()) : the_post();
                <div class="post">
                	<div class="title">
                    	<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                    	<?php if(!is_page()){ ?><p>Posted by <?php the_author() ?> on <?php the_time('F jS, Y') ?></p><? }; ?>
                    </div><!-- .title -->
                    <?php the_excerpt(); ?>
                </div><!-- .post -->
    <?php endwhile; endif; ?>
  3. Rev. Voodoo
    Volunteer Moderator
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.