### Digging into the post ranking code

The post ranking algorithm is included in the plugin and written here

```function wpeddit_post_ranking(\$post_id){
\$x = get_post_meta(\$post_id, 'epicredvote', true );
if(\$x == ""){
\$x = 0;
}
\$ts = get_the_time("U",\$post_id);
if(\$x > 0){
\$y = 1;
}elseif(\$x<0){
\$y = -1;
}else{
\$y = 0;
} 	\$absx = abs(\$x);
if(\$absx >= 1){
\$z = \$absx;
}else{
\$z = 1;
}
\$rating = log10(\$z) + ((\$y * \$ts)/45000);
update_post_meta(\$post_id,'epicredrank',\$rating);
return \$rating;
}```

In mathematical notation the hot algorithm looks like this: ### Effects of submission time

Following things can be said about submission time related to story ranking:

• Submission time has a big impact on the ranking and the algorithm will rank newer stories higher than older
• The score won’t decrease as time goes by, but newer stories will get a higher score than older. This is a different approach than the Hacker News’s algorithm which decreases the score as time goes by

Here is a visualization of the score for a story that has same amount of up and downvotes, but different submission time: ### The logarithm scale

The hot ranking uses the logarithm function to weight the first votes higher than the rest. Generally this applies:

• The first 10 upvotes have the same weight as the next 100 upvotes which have the same weight as the next 1000 etc…

Here is a visualisation: Without using the logarithm scale the score would look like this: Reddit is one of the few sites that has downvotes. As you can read in the code a story’s “score” is defined to be: 