Title: Hardcoding Firestats Popular Posts into sidebar.php
Last modified: August 19, 2016

---

# Hardcoding Firestats Popular Posts into sidebar.php

 *  799749
 * [17 years, 10 months ago](https://wordpress.org/support/topic/hardcoding-firestats-popular-posts-into-sidebarphp/)
 * Hi there, I love Firestats, so now I’m trying to hard code them into my themes.
 * I could get the Widget Popular Posts working very easily, but the PHP code is
   giving me a lot more trouble.
 * Could someone give me a sample PHP code for retrieving the 5 most popular posts?
   I’ve tried doing this with PHP and monumentally failed – I happen to be really
   bad with PHP.
 * I’d be very grateful for any help on this!!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter 799749
 * [17 years, 10 months ago](https://wordpress.org/support/topic/hardcoding-firestats-popular-posts-into-sidebarphp/#post-825799)
 * No-one has sample code where they’ve done this with Firestats..?
 *  Thread Starter 799749
 * [17 years, 10 months ago](https://wordpress.org/support/topic/hardcoding-firestats-popular-posts-into-sidebarphp/#post-825839)
 * The very friendly and helpful Omry gave me a hand with this. Here is the result:
 *     ```
       <?php if ( function_exists('fs_get_firestats_path') )
       {
               echo '<li>';
               echo '<h2>5 Most Popular Posts</h2>';
   
               $FS_PATH = fs_get_firestats_path();
               require_once($FS_PATH.'/php/html-utils.php');
               $days_ago = 30;
               $num_to_show = '5';
               $generator =  create_function('',"return fs_get_popular_pages_tree($num_to_show, $days_ago, FS_URL_TYPE_POST,false, n
       ull);");
               echo fs_get_cached_data('cached_firestats_popular_pages', $generator, 3600);
       }
       ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hardcoding Firestats Popular Posts into sidebar.php’ is closed to new
replies.

## Tags

 * [firestats](https://wordpress.org/support/topic-tag/firestats/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [sidebar.php](https://wordpress.org/support/topic-tag/sidebar-php/)

 * 2 replies
 * 1 participant
 * Last reply from: 799749
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/hardcoding-firestats-popular-posts-into-sidebarphp/#post-825839)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
