Display WordPress Posts on another WordPress Blog

Following on from the post Display Your WordPress Recent Posts on a Static Page which was used to display your WordPress posts on a non-WP website on the same server. I have had several people contacting me on how to display WordPress posts on another WordPress blog. This tutorial will show you how to display your posts, associated post thumbnail images and a snippet of the content from one blog to another by fetching the data from your RSS feed using the SimplePie RSS parser which is included in the WordPress installation.

Enable Post Thumbnails in WordPress & RSS Feeds

To be able to display the post thumbnails you need to enable or check that your theme supports thumbnails and also enable post thumbnails to show up in your RSS feeds.

To display your post thumbnails in your feeds you need to add the following to your theme’s functions.php

Now we need to edit the above snippet to suit your needs. I have highlighted the lines that need to be changed. I recommend that you get the script running before making any other changes and always test it in a development environment and not in a production environment.

Line 2 Change this to the URL of the feed you want to fetch.

Line 7 Gets the latest 5 posts. This can be changed to suit your needs.

Line 11-17 This function grabs the first image that is contained in the feed.

Line 18-29 This function is used to shorten the description and not display the full blog post.

Line 30 This is the start of our output which is in the form of an unordered list.

Line 36-38 This is where our image from the post thumbnails feature should display. Please note that linking to an external blog which is not your own may result in no images being displayed.

Line 41 get_date(‘F Y’); This will display the date of the published content. This can be changed to suit your requirements. Read Formatting Date and Time to learn more.

Line 42-43 grabs the amount of comment(s) the post has received. This may not show up as it depends on your RSS feed structure.

Line 44 shorten($item-> get_description(),’150′) uses the function shorten (Line 19-29) to display the blog post to a maximum of 150 characters. This can be changed to suit your requirements.

Add the CSS

Now it’s time to spice up the content with a little CSS. Open up your stylesheet, normally style.css in WordPress. Feel free to change any of the CSS to suit your requirements.

PHP

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

#wow-feed {

background:#FFFFFF;

border:1pxsolid#AFAFB0;

width:600px;

margin:10px0;

font-size:0.8em;

}

#wow-feed li { list-style: none; }

#wow-feed .rss-image img {

width:100px;

height:100px;

padding:8px;

border:solid1px#eee;

}

#wow-feed .rss-image { width: 30%; }

#wow-feed .item {

border-bottom:1pxsolid#AFAFB0;

padding:10px;

}

#wow-feed .data {

display:inline-block;

margin-left:2%;

vertical-align:top;

width:70%;

}

#wow-feed .data h5 { font-weight: bold; }

#wow-feed .data small {

color:#8F90CB;

font-size:0.9em;

margin-right:10%;

}

#wow-feed .comment-image {

background:url("images/comments.png");

height:16px;

width:16px;

vertical-align:middle;

display:inline-block;

margin-right:2%;

}

#wow-feed .date-image {

background:url("images/date.png");

height:16px;

width:16px;

vertical-align:middle;

display:inline-block;

margin-right:2%;

}

All you need to do now is to add the images to your theme images folder. I have packed the tutorial and image files into a handy zip file, available below. If the comments and time images do not display you will need to change the image paths in the CSS to be relative to your theme image directory.

Download

Conclusion

This method of displaying your posts in another blog is fairly limited as there is only so much information contained in a RSS feed. If you have any questions or maybe have a better solution feel free to comment.

Previous Article

Connect & Subscribe

Popular Topics

About

Did you know that WorldOWeb was initially designed to inform people on new software and security for Windows? These days I post on things I come across in the technology world, throwing in the occasional tutorial and review. Find out More

Supports

As I am a caring person I support a local charity by maintaining and designing for Alfie's Trust