How to call up a feed from a multisite subdirectory to a php page outside of WP?
-
Likely this question has been posted before (and I’m not using the correct terminology in my unsuccessful searches); apologies for any duplication.
I recently changed over to using MultiSite for client previews of their WP sites/blog portions of their sites on my server before taking the sites live on the client’s server.
Recently I built a main (non WP) site + a similarly-formatted custom blog (WP). The main (non-WP) site sits in a top-level folder of my pixel-relish.com server. WP is installed at the same diretory-level (folder name “wp”), but then, being part of multisite, the blog’s content files sit in a subdirectory to wp, namely wp/retailblog.
Within the main site (within a folder at the same level as the “wp” folder), I want to call up a feed of recent blog posts. I’d successfully done this with the client’s previous site (non-multisite) via the following to the top of the page (before doctype):
— Added
<?php // Include WordPress define('WP_USE_THEMES', false); require('retailblog/wp-load.php'); query_posts('showposts=3'); ?>
where “retailblog” is the name of the folder in which the blog sits on the client’s server.
Then, within a layout div in the body of the page where appropriate, adding…
<?php while (have_posts()): the_post(); ?> <h6 class="plain"><a href="../retailblog/"><?php the_title(); ?></a></h6> <?php endwhile; ?>
Ignore the h6 and a-link styling.
I had no problem editing the top-of-page code to find the wp folder locally in my multisite setup (the wp-load.php file sits in the WP root directoy, aptly called “wp” in this cae), however, not being well versed in php, I cannot figure out how to call up the correct database. Can anyone help? This is the error I get: https://pixel-relish.com/cbm2-foundation/index.php
Here is the NON-PHP version of the main (non-wp) site’s home page; currently I have placeholder paragraphs/entries in the News & Events sidebar where I want the feed to appear: https://pixel-relish.com/cbm2-foundation/
And here is the parallel blog; I’d like to feed the first six or so titles into the main site’s News & Events sidebar: https://pixel-relish.com/wp/retailblog/
Once I move the main site and blog over to the client’s servers, multisite will no longer be complicating things (no multisite needed), but still I’d like to test the page — and formatting of the entries pulling in — before I move the sites over.
Make sense?
Here is the old site I long, long, long ago built for the same client. The blog feed in action is working in the lower righthand corner: https://cbm1.com. I’m trying to accomplish the same basic feed (I can figure out how to increase the # of items ??
Thanks!
- The topic ‘How to call up a feed from a multisite subdirectory to a php page outside of WP?’ is closed to new replies.