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.

Embed Wordpress Blog Posts on PHP Page

Featured Replies

Have been trying to work around this for weeks and I am so stuck.

 

My site is in HTML/CSS.

 

I created a blog theme in Wordpress to match my site and I'm pleased with the way it turned out. All I want to do is display the last 3 posts on the index page.

 

My index page is currently a htm file, but I've read I will need to make it a php file in order for this to work.

 

So I've changed the extension, followed numerous tuts and it will not work.

 

The blog is up and running fine http://www.edenstreet.net/blog

 

The page I'm using to embed the posts is currently http://www.edenstreet.net/test.php

 

Any help or pointers as to where I'm going wrong would be appreciated. Apart from contact forms I'm a PHP newbie!

you will need to connect to the wordpress database, so have

<?php require('.blog/wp-blog-header.php'); ?>

at the top of the oa

 

now on the page add

<?php $recent = new WP_Query("showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<?php endwhile; ?>

 

that should work, but untested

  • Author

Thanks for your reply. That was near to the code I was using. For some reason it's not working.

 

The page doesn't even seem to be recognising the require function.

go and ask at the wordpress forums at www.wordpress.org as they will have a lot more knowledge about this, it may be that the code is slightly out

  • Author

Thanks again. I posted on the forum a while ago but no one replied. Will keep trying.

Code I've used successfully is

 

<?php
// Include Wordpress
define('WP_USE_THEMES', false);
require('./wordpress/wp-blog-header.php');
query_posts('showposts=10');
?>
<!-- mini loop for the excerpts -->
                       <?php while (have_posts()): the_post(); ?>
                          <h2><?php the_title(); ?></h2>
                             <?php the_excerpt(); ?>
                          <p><a href="<?php the_permalink(); ?>" class="text1">Read more...</a></p>
                       <?php endwhile; ?>
                       <!-- end the mini loop -->

 

edit - just looked at your page it shows

< ?php require('/blog/wp-content/themes/edenstreet/header.php'); ?> 

 

try using

<?php require('./blog/wp-content/themes/edenstreet/header.php'); ?> 

  • Author

Thanks for your reply. I made the change, which I think I've done before. I've tried so many tuts.

 

Now the page has just gone blank white. I think there must be something wrong with my configuration. The blog works fine on its own, other php files work on the server. I really don't know what is wrong with it.

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.