How can I add wordpress posts into my html site the blog is located at myurl.com/blog I have looked online but I don't see any comprehensive tutorials. So I want to be able to have a section on my site that will fetch the posts from the wordpress page, any help would be greatly appreciate. Thank you.
Asked
Active
Viewed 84 times
0
-
Is your HTML site and the WordPress site on the same host? – Jun 07 '18 at 22:20
-
Yes my website and Wordpress are hosted at the same site.. I have my main .com and the Wordpress is installed to the .com/blog folder – Taz Conway Jun 07 '18 at 23:36
-
Is the blog myurl.com/blog already an existing WordPress site or are you trying to create it? – Jun 08 '18 at 01:17
1 Answers
0
The simplest method is in the WordPress Codex: Integrating WordPress with Your Website « WordPress Codex.
It doesn't get any simpler. Call the wp-blog-header.php file in the header of the index.html file of your html site.
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>
And then use a standard loop to load posts on the page you want to show the posts:
<?php
require('/the/path/to/your/wp-blog-header.php');
?>
<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php
endforeach;
?>
Update:
To determine if PHP is running on your server, use FTP to upload a plain text file called phpinfo.php with only this line in it and no whitespace at the top of the file:
<?php phpinfo(); ?>
Then go to yoursite.com/phpinfo.php - or yoursite.com/somefolder/phpinfo.php and you should see a screenfull of PHP configurations. If you don't, PHP is not running. Ask GoDaddy about it.

BlueDogRanch
- 721
- 1
- 16
- 43
-
this doesn't work for me, its like the php doesn't work within my html site/ – Taz Conway Jun 07 '18 at 21:33
-
-
hi, it says I have PHP Version 7.1.16 when I uploaded the php file so it is enabled... the loop for whatever reason doesn't seem to work :/ – Taz Conway Jun 10 '18 at 11:45
-
where is the header of the index.html file, I have been putting the first piece of code at the extreme top of the index.html file, should I located somewhere lower? – Taz Conway Jun 10 '18 at 11:52
-
Ok, php is running. The header call goes at the top of index.html, with the `` around it. You should look in your php error log to see what might be wrong; where the log is depends on your system. – BlueDogRanch Jun 11 '18 at 02:01
-
hi, I have contacted my host provider and they advised you can only use php within a .php file and not into html.. would you know if this is correct? – Taz Conway Jun 13 '18 at 23:12
-
Search SE: https://stackoverflow.com/questions/11312316/how-do-i-add-php-code-file-to-html-html-files – BlueDogRanch Jun 15 '18 at 03:46
-