Quantcast
Viewing latest article 1
Browse Latest Browse All 4

Answer by Luiz Cruz for Display Wordpress posts in other webpage

Thanks for all the help.

As I said, I installed Wordpress on site.com/blog and I wanted site.com's homepage (index.php) to show, say, 3 Wordpress posts on the "News" section of the page.

So, for site.com I had to add:

<div id="news"><p>Here you can see our latest News</p><?php define('WP_USE_THEMES', false);require('blog/wp-blog-header.php'); //Note the folder hierarchy to find wp-blog-header.php?><?php$my_query = new WP_Query('showposts=3'); //"3" being the number of posts to be shownwhile ($my_query->have_posts()): $my_query->the_post();?><h3><?php the_title() ?></h3> //This makes the post title show inside a h3 tag<p><?php the_excerpt() ?></p> //This makes the post excerpt show inside a p tag<?php endwhile;?></div>

Viewing latest article 1
Browse Latest Browse All 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>