• I want to change the layout of the default Calendar widget. I prefer my calendar to have the start of the week as Sunday and not Monday, so that my calendar displays “Sun Mon Tues Wed Thur Fri Sat” instead of the default “M T W T F S S”.

    Where is the code to edit all this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • And did you try your admin panel > Options > General: Date and Time options?

    Thread Starter mellojoe

    (@mellojoe)

    Well, no, actually. I didn’t think about that.

    Is there no way to get into the code and define the table layout? I see when I view the online source that it uses variables like <caption> and <thead>, etc.

    I’d like to see where the code is generated.

    Too bad – you should always check first your options…

    Everybody that I know of – define the layout in CSS, not in the code.

    And a final note: If you feel comfortable hacking core files and rewrite the code… I assume you should be able to find the files, too.
    Sorry, I never hack core files, so I really don’t know.

    Thread Starter mellojoe

    (@mellojoe)

    Well, I did change the Options. And that worked fine.

    I’ve searched around in some of the files, but I just can’t find the code where it lays out the table (aparently the original coders used table, caption, header, etc to lay out the calendar).

    Anyone out there?

    I see the section in the “widgets.php” that reads function wp_widget_calendar and function wp_widget_calendar_control, but I can’t see how they build the table with these small functions.

    I’d like to know where the calendar code is generated so that I might assign my own CSS to it.

    Anyone?

    I’d like to know where the calendar code is generated so that I might assign my own CSS to it.

    Adding CSS does not require editing the core code. Just add whatever CSS you want to your theme’s style.css file.

    Adding CSS does not require editing the core code. Just add whatever CSS you want to your theme’s style.css file.

    Ok, but say you’d like to change the position of the links at the bottom (previous and next month) to be at the top of the calendar next to the title of the month, how would you on do this? Template-functions-general.php is just so massive, I wouldn’t now where to begin :s And it kind of sucks to alter the core code. I’d rather edit the template somehow.

    Any advice?

    I just found this code in Template-functions-general.php. Maybe I have to change something here?

    <tfoot>
    	<tr>';
    
    	if ( $previous ) {
    		echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
    		get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)],
    			date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
    	} else {
    		echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    	}
    
    	echo "\n\t\t".'<td class="pad">&nbsp;</td>';
    
    	if ( $next ) {
    		echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
    		get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($next->month, 2)],
    			date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' &raquo;</a></td>';
    	} else {
    		echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
    	}
    
    	echo '
    	</tr>
    	</tfoot>

    “tfoot” probably refers to the foot of the calendar, but I tried moving this piece of code ABOVE the “thead” part, but nothing really happened.

    What am I doing wrong here?

    Nothing happens to my calendar at all when I alter code in the Template-functions-general.php. That doesn’t make any sense. I’ve removed huge chunks of code just to test, but nothing happens.

    Why?

    I still want to change the default wp-calendar, but I don’t know where to begin.

    Any advice would be great!

    Nothing happens to my calendar at all when I alter code in the Template-functions-general.php.

    At the end of get_calendar, you’ll fined this:

    wp_cache_set( 'get_calendar', $cache, 'calendar' );

    Apparently the calendar gets cached somehow. I’m not sure how to force it to flush the cache, but that’s probably why you’re not seeing any changes.

    If you don’t want to modify the core files, you could always copy function get_calendar (the whole thing) into your theme’s functions.php, rename the function, modify as wanted, and then call the renamed function in your sidebar.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Edit “Calendar” Function? Where is the code for the Calendar?’ is closed to new replies.