Display articles from wordpress on a site other than Wordpress.

The easiest way to post articles posted on a Wordpress site (from a specific category) to another non-WordPress site built in PHP / MySQL.

I understand that wordpress uses MySQL, so in theory I could connect via PHP to the database and directly pull the contents out if I can calculate the scheme used

I know that I can get an RSS feed - is there a parser available that I could use to get the entire content of the article, including images, etc.

+4
source share
2 answers

Wordpress content on non-Wordpress pages in the same domain

This is a very database-rich method as it loads almost all of Wordpress backstage, but it is simple and well-documented:

Show Wordpress Content Outside Your Blog

It is assumed that the Wordpress blog is on the same server as the content other than Wordpress, and you can link to wp-load.php


Wordpress content on non-Wordpress pages in a remote domain

One of the simplest simplest methods of syndicating content in a remote domain is to parse an RSS feed using MagpieRSS .

A large number of code samples are available:

To get an RSS feed for a specific category, use something like

http://www.example.com/?cat=42&feed=rss2

http://example.com/category/categoryname/feed

More details here:

+4
source

If other pages are located on the same server, you can do this by downloading the wp-load.php file

First add this to the top of the page to load wp-load.php

<?php // Include WordPress define('WP_USE_THEMES', false); require('./wordpress/wp-load.php'); query_posts('showposts=1'); ?> 

Then you can encode all the content with:

 <?php while (have_posts()): the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_excerpt(); ?> <p><a href="<?php the_permalink(); ?>">Read more...</a></p> <?php endwhile; ?> 

Checkout this link: Loop (Wordpress Codex)

0
source

Source: https://habr.com/ru/post/1344731/


All Articles