Seattle Web Design
Blog > How To Embed WordPress Posts in a Website Page

Meet the author:
Jill Olkoski

Jill has a MA in Clinical Psychology, a BS in Computer Science, and a BS in Mechanical Engineering.

She currently owns Aldebaran Web Design in Edmonds (near Seattle WA) and enjoys educating her clients on topics related to small business website design.

In Jill's previous life, she spent 17 years in the engineering and quality organizations of a Fortune 100 tech company.


How To Embed WordPress Posts in a Website Page

March 28th, 2014

Sometimes you want to display the last few posts of a WordPress blog on a regular website page, assuming the WordPress installation is in a sub directory of the website. This is an alternative to using an RSS to HTML method. I’m saving the code here for myself, and in the event it helps another developer.

define(‘WP_USE_THEMES’, false);

// changes excerpt length from the default 55 to 20
function custom_excerpt_length( $length ) {
return 20;
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

// changes the default exerpt […] to a read more
function new_excerpt_more( $more ) {
return ‘…<em><a href=”‘. get_permalink( get_the_ID() ) . ‘”>more</a></em>’;
add_filter( ‘excerpt_more’, ‘new_excerpt_more’ );

global $post;
$args = array( ‘posts_per_page’ => 3 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :    setup_postdata($post); ?>
<div><strong><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></strong><br /><?php the_excerpt(); ?></div> <br />
<?php endforeach;

J. Olkoski
Aldebaran Web Design, Seattle
Jill Olkoski has a BS in Engineering, a BS in Computer Science and an MA in Clinical Psychology. She delights in using her advanced technical and psychological skills to help small business owners develop cost-effective and successful websites.

Comments are closed.

 ©2006 - © Aldebaran Web Design Seattle, A DBA of Aldebaran Services LLC
Blog Email Subscription:
Search Blog Articles: