January 6, 201115 yr I have created an HTML site and on the bottom right of the page I want to include my latest 2 posts from a Wordpress site. The box is 300px by 180px. Can anybody point me in the right direction?
January 6, 201115 yr Easiest way is to code the site into Wordpress - or build the site on Wordpress. That's what should have happened anyway. You could manually fetch the posts from the database with some PHP. That wouldn't work on .HTML files though and would require an Apache server. Edited January 6, 201115 yr by andyl
January 6, 201115 yr Easiest way is to code the site into Wordpress - or build the site on Wordpress. That's what should have happened anyway. You could manually fetch the posts from the database with some PHP. That wouldn't work on .HTML files though and would require an Apache server. People still build static sites???? Like the above post says just install another workpress installation and use any of the hundreds of plugins to show your feed or how about a flash rss reader : http://rsstool.sanriotown.com/ or there are php (http://www.scriptol.com/rss/rss-reader.php) and javascript ones (http://p3k.org/rss/) out there cheers Andy Edited January 6, 201115 yr by Dx3webs
January 7, 201115 yr Author People still build static sites???? If im just starting out you have to work at the very basics to improve. Don't want to start cheating with CMS's until ive sorted out the basics. Cheers for you advice about RSS feeds, though.
January 7, 201115 yr Not very many helpful responses here so far and a few very opinionated folk too - yes people still build static sites - get over it! So I thought I'd chip in and help as I've pulled wordpress posts from a blog into a static html page in the past and it's not an easy thing to find a solution for on Google as I remember searching for ages and I think I got help on this forum in the end. Hope this helps... Right at the top of your HTML code before the doctype insert: <?php // Include Wordpress define('WP_USE_THEMES', false); require('./blog/wp-blog-header.php'); query_posts('showposts=3'); ?> I've got showposts=3 above as I was pulling in the latest three posts - just change that to whatever number you want. Then insert this code into the HTML where you want the blog posts to appear: <?php while (have_posts()): the_post(); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php // Display content above the more tag $more = 0; the_content("More..."); ?> <br /> <?php endwhile; ?> You'll want to change the code a bit if you don't want the permalink to be an H2 etc, but this should at least get you on the right track - it worked for me at the time, hope it does for you.
January 10, 201115 yr Eskymo's solution will only work if your static page is hosted on the same site as your wordpress, which is why I asked above if it was going to be on the same site, on the same server or neither of these. As then someone could of given you the best solution based on where you wanted the data to go. If it is on the same site, Eskymo's is fine, except you would obviously point to where your wordpress is stored if it isn't in a blog folder. If it is a different site but on the same server you can use this: <?php // Include WordPress define('WP_USE_THEMES', false); require('/var/www/yoursite.com/wordpress/wp-load.php'); query_posts('showposts=3'); ?> although some php may restrict this and cause it not to work. If it is on a different site and not on the same server or you want to pull from multiple blogs then RSS is the way forward.
Create an account or sign in to comment