Skip to content

Instantly share code, notes, and snippets.

@jclapp23
jclapp23 / template-general.php
Created July 25, 2013 13:30
WP_Cal_Demo # 1
<?php
// Get days with posts
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
AND post_type = 'post' AND post_status = 'publish'
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
if ( $dayswithposts ) {
foreach ( (array) $dayswithposts as $daywith ) {
$daywithpost[] = $daywith[0];
@jclapp23
jclapp23 / gist:6079671
Created July 25, 2013 13:32
WP_Cal_Demo # 2
<?php
// Get days with posts
$dayswithposts = $wpdb->get_results("SELECT (FROM_UNIXTIME(`wp_postmeta`.`meta_value`,'%d')) as dom ,
`wp_postmeta`.`post_id` , `wp_posts`.`guid` , `wp_posts`.`post_title`
FROM $wpdb->postmeta
LEFT JOIN `wp_posts` ON `wp_postmeta`.`post_id` = `wp_posts`.`ID`
WHERE `wp_postmeta`.`meta_key` = 'event_startdate'
AND `wp_posts`.`post_status` = 'publish'
AND `wp_postmeta`.`meta_value` >= UNIX_TIMESTAMP( '{$thisyear}-{$thismonth}-01 00:00:00' )
@jclapp23
jclapp23 / gist:6079693
Created July 25, 2013 13:34
WP_Cal_Demo #3
<?php
$ak_titles_for_day = array();
$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
."FROM $wpdb->posts "
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
."AND post_type = 'post' AND post_status = 'publish'"
);
if ( $ak_post_titles ) {
@jclapp23
jclapp23 / gist:6079709
Last active December 20, 2015 05:39
WP_Cal_Demo #4
<?php
if ( $dayswithposts ) {
foreach ( $dayswithposts as $daywith ) {
$daywithpost[] = $daywith->dom;
$post_title = esc_attr( apply_filters( 'the_title', $daywith->post_title, $daywith->post_id ) );
if(empty($ak_titles_for_day)){
$ak_titles_for_day[$daywith->dom]= array ();
@jclapp23
jclapp23 / gist:6079731
Created July 25, 2013 13:40
WP_Cal_Demo #5
<?php
$calendar_output .= '<td>';
if ( in_array($day, $daywithpost) ) // any posts today?
$calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
else
$calendar_output .= $day;
$calendar_output .= '</td>';
@jclapp23
jclapp23 / gist:6079757
Created July 25, 2013 13:43
WP_Cal_Demo #6
<?php
$calendar_output .= '<td>';
if ( in_array($day, $daywithpost) ){
$title_div = "<div>";
foreach($ak_titles_for_day[$day] as $ak_title){
$title_div .= "<a href='".$ak_title['url']."' title='".$ak_title['title']."'>".$ak_title['title']."</a><br/>";
}
$title_div .= "</div>";
$calendar_output .= "<span>$day</span>".$title_div;
@jclapp23
jclapp23 / gist:6079773
Created July 25, 2013 13:45
WP_Cal_Demo # 6
$('#wp-calendar span').hover( function () {
$(this).next().show();
},
function () {
$(this).next().hide();
});
$('#wp-calenda div').hover( function () {
$(this).show()
},
@jclapp23
jclapp23 / gist:6080324
Created July 25, 2013 14:37
WP_Cal_Demo #7
<?php
$calendar_output .= '<td style="position:relative">';
if ( in_array($day, $daywithpost) ){ // any posts today?
$title_div = "<div class='event-titles'>";
foreach($ak_titles_for_day[$day] as $ak_title){
$title_div .= "<a href='".$ak_title['url']."' title='".$ak_title['title']."'>".$ak_title['title']."</a><br/>";
<?php
/*** turn on error reporting ***/
error_reporting( E_ALL );
/*** an array of test values ***/
$values = array( $var, null, 0, false, 100, '');
echo '<tr>';
echo '<td>isset()</td>';
foreach( $values as $val )
{
@jclapp23
jclapp23 / general-template.php
Created October 10, 2013 02:45
general-template.php
<?php
/**
* General template tags that can go anywhere in a template.
*
* @package WordPress
* @subpackage Template
*/
/**
* Load header template.