How to Create an RSS Syndicator Site Using WordPress

In this tutorial, I will share on how to create a syndicator, or ping site, using WordPress functionality. This function can be useful for owners who want to create an article directory which will allow their users to submit articles to their website using RSS. To give some overview on how such a site may look, I've setup a Demo RSS Site for this tutorial. Now let's begin.


Step 1 Setting Up A Feed Placeholder

First we need to setup a place where users can add their RSS feeds. At first I thought using the existing WordPress user profile section would be sufficient, but if we want to allow multiple web submissions, it can be troublesome. We will setup a new custom post type to handle the URL for the user RSS Feed. You can learn further about custom post types by reading the Custom Post Type Helper Class article.

We will need 2 fields only for the custom post type, a title and a place to add the URL (I use the excerpt column to keep everything simple)

Save the following code in new file (rss_feed_functions.php) and upload it into the following folder /wp-content/mu-plugins/. The function will be loaded without a need to activate it like a normal plugin.


Step 2 Setup Custom Page RSS Feed Submission

After we have setup our custom post type to keep the RSS URL, we need to setup a page where a user can submit their URL. The following function will create a form and you can include it into any page using the shortcode we define in the code.

We need an input field to allow a user to add a title and URL for the RSS.

Next thing, we need to handle the form once it is posted. The following code will allow us to prepare the query to insert the data to our website.

But before we insert all the data we received from the form, we would want to validate the feed URL and the title first. To easily validate the feed URL, we will use the following WordPress function to check if the feed URL return a valid content.

If everything works well, we insert the feed data into the database. The complete function with shortcode functionality will look like the code shown below, we can add the complete function into our rss_feed_functions.php file.

Now we can use the shortcode [rss_form_submit] in any of our pages and you can style the form to fit your website design. You may want to allow only registered user to be able to see and use that page.


Step 3 Article Submission via Feed URL

Since we already have the feed URL in our database, next we want to process the article that users want to submit to our ping site. We will need a new page for this, and to ensure the function can be used on any themes, we will use the same approach as the feed URL submission for the article submission, using a function with shortcode.

First of all, we need to read the feed from the current user.

If there is RSS feed found, then we can start loop the feed URL, and fetch the latest article from the feed.

Now we already have the first article to be inserted into our website. Before we continue with adding it into the database, it is best to check first if the article already exists on our website. We will check the title of the feed item if it already exists, this is just a basic method, you can check more attributes to ensure there are no duplicated article in the database.

We can now process the data we fetch from the feed into our database. To make it simple for our user, we will include the submit form directly after we fetch and check the URL.

In the example, we process the title, content, permalinks and date to be inserted into our database. Users will see the title and the submit button like the screenshot below.

Last step we need to do, is to insert the data into the database. We prepare the statement before we run the query.

We will process these details first before we insert the extra data into our custom meta box.

Now all the article data is successfully inserted into the database. We now have a syndicator or ping site ready to be use. There are more possibilities you can add to enhance the quality of your ping site, but this was a simple introduction.


Conclusion

I have included the complete source code ( link at the top of this article ) that I use on the Demo RSS Site. If you have any suggestion or improvement for this tutorial, I'm looking forward to reading the ideas and suggestions in the comments below.

Tags:

Comments

Related Articles