Automatically Updating Publish Date Bug

You could also hook into the save_{$post_type} action, which fires only when a certain post type is updated. This hook passes to post’s ID to the callback function: add_action( ‘save_post’, ‘my_callback_function’ ); function my_callback_function( $post_id ){ if ( ! wp_is_post_revision( $post_id ) ){ // Unhook this function so it doesn’t loop infinitely remove_action(‘save_post’, ‘my_callback_function’); // … Read more

Displaying the Month and Year that a page was Created?

This worked for me. I created variables for both the month of the post and the year of the post. <?php $post_month = get_the_time(‘F’); $post_year = get_the_time(‘Y’); if ( is_page(‘about/mission-statement/’)) { echo ‘<time>’ . $post_month . ‘ ‘ . $post_year . ‘:’ . ‘</time>’; } ?>

display month in french in wordpress/php?

there is a custom function in wordpress called date_i18n. so basically you do echo date_i18n( ‘H:i d-m-Y’, $ts ); without the setLocale stuff.. find the function date_i18n and its parameters here. you could even build in your translation all in there, without the language check before: date_i18n( __( ‘H:i d-m-Y’, ‘textdomain’ ) ); (replace ‘textdomain’ … Read more

How to render a time-of-day string like ’16:42′ with a site’s chosen time format?

The trick here is using wp_date() in a peculiar way, giving it the time of day in seconds (as if it were 1970-01-01 16:42:18), then asking for it to be formatted in UTC. $time=”16:42:18″; if ( preg_match( ‘/^\d\d:\d\d:\d\d$/’, $time ) ) { //validate the $time $ts = intval( substr( $time, 0, 2 ) ) * … Read more

Change the ‘published on’ text?

Use a gettext filter and match against the text. add_filter( ‘gettext’, ‘filter_published_on’, 10000, 2 ); function filter_published_on( $trans, $text ) { if( ‘Published on: <b>%1$s</b>’ == $text ) { global $post; switch( $post->post_type ) { case ‘your-posttype’: return ‘Whatever on: <strong>%1$s</strong>’; break; default: return $trans; break; } } return $trans; } The alternative would be … Read more