Skip to content

Instantly share code, notes, and snippets.

@chriscoyier
Created April 28, 2011 01:33
Show Gist options
  • Save chriscoyier/945619 to your computer and use it in GitHub Desktop.
Save chriscoyier/945619 to your computer and use it in GitHub Desktop.
commentgraph.php
<?php
/*
Template Name: Comment Graph
*/
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Comment Graph</title>
<style>
#chart { margin: 50px 0; height: 400px; }
#chart > div { width: 1px; background: red; display: inline-block; }
</style>
</head>
<body>
<?php query_posts('posts_per_page=-1'); ?>
<div id="chart">
<?php
while (have_posts() ) : the_post();
$numComments = get_comments_number();
$percentage = $numComments / 3;
echo "<div style='height: $percentage%;'></div>";
endwhile;
?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment