Skip to content
TarekNabil.Net
All projects

Project · WordPress plugin · Private

WP Custom Post Order

A custom scoring system that orders a WordPress blog's posts by favorites, a popularity constant and post age, so the newest and most-favorited posts appear first.

Role
Solo developer
Year
2011
Tags
WordPressPHPWordPress PluginMySQLPost MetajQueryJavaScriptCookies
A blog archive page with a three-column grid of post cards ordered by score, from "Score = 982" on the first card down to "Score = 352" on the last; each card has an image, headline, an "Add to favorites" star with favorite counts, and an excerpt, and the first card is marked New A blog archive page with a three-column grid of post cards ordered by score, from "Score = 982" on the first card down to "Score = 352" on the last; each card has an image, headline, an "Add to favorites" star with favorite counts, and an excerpt, and the first card is marked New

About the Project

WP Custom Post Order is a scoring system I built on a client’s request. It sorts a blog’s published posts by a score. The score combines the number of times a post was favorited, a popularity constant set in the admin, and the post’s age.

The client’s site had thousands of posts, so the sort had to stay correct as favorites and dates changed. The favorites feature comes from the open-source WP Favorite Posts plugin, which I extended with the scoring logic and an integration with the theme’s post loop.

Problem

The blog had thousands of posts, and the default order showed old posts as often as new ones. The client wanted new posts to appear first, with popular posts ranked above the rest, and the weights adjustable without changing code.

Role

Solo developer. I designed the scoring algorithm with the client, wrote the scoring functions, added the admin settings for the constants, integrated the ordering with the theme’s archive loop, and tested the result on a staging site with 2,500 posts.

Stack

PHPWordPress Plugin APIWP_QueryMySQLTemplate hooksShortcodesWidgetsAdmin menuOptions and post metajQueryCookies and user metaTheme template integration

Outcome

100% Project certified as complete and fully satisfactory by the client.
2,500 Posts in the staging test set. Posts displayed in the correct order, with new posts first and favorited posts prioritized.
Status: Completed (2011).

FAQ

How is the order decided?

Each post gets a score: stored maximum score, plus the favorites count times a popularity constant, plus a date constant times the number of days since publication. Newer posts score higher, and popular posts rise.

Who controls the weights?

The admin sets the popularity and date constants in the WP Favorite Posts settings.

Do readers need accounts?

No. Guests save favorites in cookies. Logged-in users save them in their user data.

Which WordPress versions?

The base plugin, WP Favorite Posts, was tested up to WordPress 3.2.1.

Get in Touch

Reach out for any reason: a role, a project, or a question.

Send a message