_get_last_post_time [ WordPress Function ]
_get_last_post_time ( $timezone, $field )
| Access: |
|
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: get_post_time, get_lastpostdate, get_lastpostmodified, get_last_updated, get_post_meta
Retrieve latest post date data based on timezone.
Source
<?php
function _get_last_post_time( $timezone, $field ) {
global $wpdb;
if ( !in_array( $field, array( 'date', 'modified' ) ) )
return false;
$timezone = strtolower( $timezone );
$key = "lastpost{$field}:$timezone";
$date = wp_cache_get( $key, 'timeinfo' );
if ( !$date ) {
$add_seconds_server = date('Z');
$post_types = get_post_types( array( 'public' => true ) );
array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) );
$post_types = "'" . implode( "', '", $post_types ) . "'";
switch ( $timezone ) {
case 'gmt':
$date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
break;
case 'blog':
$date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
break;
case 'server':
$date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
break;
}
if ( $date )
wp_cache_set( $key, $date, 'timeinfo' );
}
return $date;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- #17455 (Add $post_type argument to get_lastpostdate ...
Add $post_type argument to get_lastpostdate/get_lastpostmodified/ _get_last_post_time. Reported by: duck_, Owned by: Priority: normal, Milestone: Awaiting ...
core.trac.wordpress.org - error_log - Back To Awake
... WP->main, WP->send_headers, get_lastpostmodified, _get_last_post_time [02 -Feb-2012 04:27:09] WordPress database error MySQL server has gone away ...
www.backtoawake.com - [26-Jun-2011 22:28:33] PHP Warning: require(./wp-blog-header.php ...
... WP->main, WP->send_headers, get_lastpostmodified, _get_last_post_time [15 -Aug-2011 20:07:51] WordPress database error MySQL server has gone away ...
tattoodvds.com - get_lastpostdate | A HitchHackers guide through WordPress
Feb 12, 2011 ... returns:The date of the last post. Defined filters. get_lastpostdate apply_filters( ' get_lastpostdate', _get_last_post_time( $timezone, 'date' ) ...
hitchhackerguide.com