Created
October 12, 2012 23:19
-
-
Save tollmanz/3882203 to your computer and use it in GitHub Desktop.
Cache Google Analytics Data with Variable Args
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function zt_generate_top_posts( $args ) { | |
// Queries GA, relates to internal posts | |
$top_post_objects = zt_magic_GA_querier( $args ); | |
// If no objects are returned, exit the function | |
if ( false === $top_post_objects ) | |
return false; | |
// Start building the HTML | |
$html = '<ul>'; | |
// Loop through post objects and generate HTML | |
foreach ( $top_post_objects as $post_object ) { | |
$html .= '<li>'; | |
$html .= '<a href="' . esc_url( $post_object['permalink'] ) . '">'; | |
$html .= esc_html( $post_object['post_title'] ); | |
$html .= '</a>'; | |
$html .= '</li>'; | |
} | |
$html .= '</ul>'; | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment