Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Adding latest wordpress post to website?

Featured Replies

Hello i am creating a basic landing page as such for my online store.

 

I am wanting to put the latest post from my wordpress blog onto the webpage that i am making.

 

How do i go about this?

^^^ same question as the above...

If your landing page and WordPress are running off the same install then it's pretty simple, otherwise your best route is to grab the WP RSS feed and use that to display the posts content.

  • Author

Different software.

 

I have my store (oscommerce) and then my landing page is just a normal html page.

 

The blog is in the same directory as both.

 

I was thinking i would have to go down the rss feed route :)

Different software. I have my store (oscommerce) and then my landing page is just a normal html page.

 

I was thinking i would have to go down the rss feed route :)

 

I would suggest getting a small PHP script to pull the latest post from the WordPress database because of the overhead. All you need is the latest post and if you pull data from the RSS feed, WordPress first queries the database after running through the plugin framework and processing any actions or filters, then it turns the post data into RSS markup, next you have either a Javascript that gets the browser to request for the RSS and turn it into a part of the page as markup or have a PHP script to do it for you. But then again, if you're not on shared hosting or if you have a good shared hosting service, an RSS feed just might do it for you too.

If you are trying to put your latest wordpress posts onto a static html page here is how

 

first create a PHP file, call it blogfeeds.php

 

<?php
// Include WordPress 
define('WP_USE_THEMES', false);
require('./blog/wp-load.php');
query_posts('showposts=3'); // how many post you want to be displayed

function new_excerpt_length($length)
{
	return 15; // the number of words from the post that you want to show
}
add_filter('excerpt_length', 'new_excerpt_length');

function new_excerpt_mored($more)
{
	return ' <a href="'. get_permalink($post->ID) . '" class="more">Read more</a>'; // the readmore link format
}
add_filter('excerpt_more', 'new_excerpt_mored');




while (have_posts()): the_post(); ?>

<li>

<span class="date"><span class="day"><?php the_time('d') ?></span> <span class="month"><?php the_time('M') ?></span></span>

<h3><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h3>

<?php the_excerpt(); ?>

</li>

<?php endwhile; ?>

 

you can then put that file in the root directory

 

now to get the information from your php file into your html fil you would use a little jQuey (there are other ways to do this I just jQuery as its really easy)

 

<script type="text/javascript">
$(document).ready(function(){
 	$.get("blogfeeds.php", function(result){ 
   	$("#blogfeed").html(result);
});
});
</script>

 

and for your html you would need a place for where this is going to

 

<ul class="listA" id="blogfeed">

</ul>

 

I hope this helps.

  • 2 weeks later...

Since your homepage is static HTML, why not just build it into Wordpress? Wouldn't make it easier not having to manage an additional static homepage?

 

You could set a static homepage in wordpress by creating the page in Pages, and in settings > reading changing the homepage.

 

If the homepage has a different layout than the blog, you could just create a custom template, asign it to the homepage, and do it that way. You could even go as far as pasting your static HTML into th the custom template file, for whatever reason.

post-9028-0-49665700-1325917979_thumb.png

Edited by empek

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.