Created
July 8, 2011 01:13
-
-
Save jorgepedret/1070901 to your computer and use it in GitHub Desktop.
quick wp stuff
This file contains hidden or 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 | |
funcion get_years(){ | |
$results = $wpdb->query("SELECT DISTINCT YEAR(meta_value) as year FROM wp_postmeta WHERE meta_key = 'release_date'"); | |
echo '<select>'; | |
foreach($results as $result){ | |
echo '<option>'.$result->year.'</option>'; | |
} | |
echo '</select>'; | |
} | |
function get_posts_by_year($year){ | |
$query = "SELECT post_id FROM wp_postmeta WHERE meta_key = 'release_date' AND YEAR(meta_value) = '".$year."'"; | |
$results = $wpdb-query($query); | |
foreach($results as $result){ | |
$post = get_post($result->post_id); | |
echo $post->post_title; | |
} | |
} | |
get_posts_by_year($_GET['year']); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment