Most popular articles for wordpress


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $start = date('Y-m-d', (time() - (60 * 60 * 24 * 30)));
  3. $end = date('Y-m-d');
  4. $showpages = 10;
  5. $thispage = 1;
  6.  
  7. $login = new GADWidgetData();
  8. $ga = new GALib($login->auth_token, $login->account_id, 60);
  9. $pages = $ga->pages_for_date_period($start, $end);
  10.  
  11. echo "<ul>";
  12. foreach($pages as $page) {
  13.  
  14. $url = $page['value'];
  15. $title = $page['children']['value'];
  16. $array = array('(not set)', 'Okada Design Blog', 'Downloads | Okada Design Blog', 'Downloads « Okada Design Blog');
  17. // You need to add any words which you don't want to show in the list
  18. if(!in_array($title, $array)){
  19. $takeout = array(" | Okada Design Blog"," « Okada Design Blog");
  20. // You need to add any words which you want to delete in the list
  21. $newtitle = str_replace($takeout, "", $title);
  22.  
  23. echo '<li><a href="' . $url . '" rel="nofollow">' . $newtitle . '</a></li>';
  24. $thispage++;
  25. }
  26.  
  27. if($thispage > $showpages) break;
  28. }
  29. echo "</ul>";
  30. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.