May 19

I stumbled while installing a second WordPress blog. Everything seems to be fine: DB, PHP (first blog works), apache.conf, .. Nevertheless I received empty HTML bodies when calling a php page.

So I started debugging and finally found the problem inside my php.ini. In the moment I saw that line I remembered that I changed it to secure my server a bit ;)

open_basedir = /path-to-first-wordpress-dir/:/path-to-second-wordpress-dir/:/tmp/

After adding the path of my second WordPress installation everything was fine.

Tagged with:
Sep 06

Are you using Google Analytics to see what your readers like? Do you want to display your top posts as a widget like this:

You need the Google Analytics plugin. Next, you need to edit your sidebar.php. E.g. through Apperance > Editor > Sidebar
The following code will do the trick.

<!--sidebox start -->
<div id="top-posts" class="dbx-box">
  <h3 class="dbx-handle">Top Posts</h3>
  <div class="dbx-content">
$start = date('Y-m-d', (time() - (60 * 60 * 24 * 365)));
$end = date('Y-m-d');
$showpages = 10;
$thispage = 1;

$login = new GADWidgetData();
$ga = new GALib($login->auth_type, $login->auth_token, $login->oauth_token, $login->oauth_secret, $login->account_id, 60);
$pages = $ga->pages_for_date_period($start, $end, 10);

echo "<ul>";
$excludes = array("(not set)", "my-to-excluded-post-title");
foreach($pages as $page) {
  $url = $page['value'];
  $title = $page['children']['value'];
  if ( !(in_array($title, $excludes)) && (strpos($url, '?p=') == false) ) {
    echo '<li><a href="' . $url . '">' . $title . '</a></li>';
  if($thispage > $showpages) break;
echo "</ul>";
<!--sidebox end -->

Line by Line

Line 06 defines the number of days to consider (365)
Line 08 defines the number of posts you want to display (10)
Line 13 defines the minimum number of hits a post must have in order to be considered (10)
Line 16 defines an array with a list of excluded titles
Line 20 checks if the title is part of the excludes or if the title starts with ?p= which is in my case the prefix of a post preview

This post is inspired by Rob’s post. I just added some filtering. My first php lines of code:)


Changed line $ga = new GALib($login->auth_token, $login->account_id, 60);
to $ga = new GALib($login->auth_type, $login->auth_token, $login->oauth_token, $login->oauth_secret, $login->account_id, 60);

Tagged with:
preload preload preload