Display Your WordPress Posts In A Facebook-Style Timeline

Display Your WordPress Posts In A Facebook-Style Timeline

One sure fire way to make your WordPress site stand out from its competitors, is to be different. And if you can be different by using a technique that is already very familiar, then it can be a win-win situation.

Presenting your WordPress posts as a Facebook-style timeline is one such situation.

In this article we’ll walk-through how to implement a timeline on your WordPress site using the recently released Timeline Pro plugin.

A screengrab of the timeline
A Facebook-style Timeline can bring a familiar but intriguing dynamic to your post listing

Regardless of what you think about Facebook, it’s interface and approach to user interaction is both understood and instantly familiar to the vast majority of your potential audience. Leveraging this familiarity immediately makes your visitors feel at home with the obvious potential knock-on effects of deeper and more lasting engagement.

The good news is that implementing a Facebook-style timeline for your WordPress posts is a simple 3 step process, thanks, mainly, to the Timeline Pro plugin from Kento Themes.

Here’s a screenshot of a test site running test data from Michael Novotny‘s WP Test:

Screenshot of a timeline
A single-page website is a real possibility with the Timeline Pro plugin

The Value Of Testing

It turned out that installing the WP Test data on a test site in order to test the plugin for this article was an unintentional master stroke as the plugin is not without its bugs and I’ll go through how to fix these.

Suffice to say, plugin developers and indeed anyone building a site, would be well-advised to make sure they test their creations with data that is as comprehensive as WP Test’s.

If you are just wanting to play with Timeline Pro, then I would fully recommend using WP Test’s data. You’ll also need to install the Slim Jetpack plugin and enable Tiled Galleries.

3 Steps To Creating Your Timeline

Step 1 – Download The Timeline Pro Plugin

As I mentioned above, there are a couple of bugs in version 1.0 of this plugin, so you can either download this version and make the updates detailed later in the article, or you can download an updated version. With a bit of luck, Kento Themes will be able to update their official version soon.

Step 2 – Update The Default Settings

The plugin creates a new Admin menu item, Timeline Pro Settings. Clicking on this item allows you to set the default settings for how the timeline is displayed.

Screenshot fo the Timeline Pro settings page
Why go for anything else other than full content?

The colors and post-type can actually be overridden by the shortcode but displaying thumbnails and whether to show just the excerpt or the full content are global (which is a shame – being able to control all options on the shortcode would be preferable).

FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

I would recommend for displaying the full content. With comment display and replying being handled inline using AJAX, displaying the full content would mean never having to leave that one page and that feels far more satisfying an user experience.

Select your preferences and click on Save Changes.

Step 3 – Create A Page For The Timeline, Embed The Shortcode

Create a WordPress page as you would do normally (Pages > Add New) and in the content add the following shortcode in the body of the page:

[timeline_pro]

This will generate the timeline. Incidentally, sticky posts are honored and are, in fact, displayed full-width at the top of the timeline.

Step 4 (Optional) – Assign The Timeline Page As The Homepage

If you want to use the timeline as your homepage (and effectively have a 1 page site) then jump into Settings > Reading and set Front page displays to a static page and then select your timeline page.

Screenshot of the WordPress Reading settings
Set the home page to a static page containing your timeline

A Couple Of Fixes

Mostly, the plugin works just as expected and has excellent support for comments (inline display and replying) and inline loading of earlier posts.

There are, however, just a couple of bugs that need addressing for it to be completely usable. As I mentioned, I’ve already made these changes to this version of the plugin but I’ve documented the changes here for the sake of completeness.

Fix 1 : CSS Tweak For Ensuring Comment Count Doesn’t Wrap On (Mac) Chrome

A minor tweak to prevent the comment count wrapping. This was only happening on Chrome on OS X.

Add the following statement to the style.css:

.comments-count { white-space: nowrap; }

 

Fix 2 : CSS Tweak For Displaying Lists Correctly In Posts

The way the CSS is currently written means that any lists in the actual posts take on the styling for the timeline list itself – not what we want.

To prevent this happening, find the following near the top of style.css:

.timeline li {
display:inline-block;
margin:20px 0 !important;
padding:0;
position:relative;
text-align:center !important;
vertical-align:top;
width:50%;
}

 

And change the top line to

.timeline li.stic, .timeline li.odd, .timeline li.even {

 

Fix 3 : Code Tweak To Process Shortcodes When Outputting Post Content

The post content is output using the WordPress function get_the_content(). Unfortunately, this means that shortcodes will not be processed and will be displayed in their raw form.

To ensure that shortcodes are processed, open the index.php and replace the 2 instances of:

$timeline_pro .=  “<div class=’body’>”. get_the_content() .”</div>”;

 

With

if ($post->post_type == ‘page’) {
$content = get_the_content();
} else {
$content = apply_filters(‘the_content’, get_the_content());
}

 

For some reason that I’m not quite sure about (if anyone knows why then please let me know in the comments), using the apply_filters function for pages causes an infinite loop, hence the check to only apply filters if not a page. I’ve tested using a custom post type and that appears to work as expected.

A single-page website with access to all your posts via a mechanism that is familiar to the vast majority of users. Could your website benefit from such an approach?

Tags: