Created
January 30, 2016 12:57
-
-
Save mariokerkhof/deca58936ac7bccb315a to your computer and use it in GitHub Desktop.
MKR Helper Functions
This file contains 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 | |
// | |
// Template helper functions | |
// | |
function mkr_is_first_post( $query = false ) { | |
if ( ! $query ) { | |
global $wp_query; | |
$query = $wp_query; | |
} | |
return $query->current_post === 0; | |
} | |
function mkr_is_second_post( $query = false ) { | |
if ( ! $query ) { | |
global $wp_query; | |
$query = $wp_query; | |
} | |
return $query->current_post === 1; | |
} | |
function mkr_is_third_post( $query = false ) { | |
if ( ! $query ) { | |
global $wp_query; | |
$query = $wp_query; | |
} | |
return $query->current_post === 2; | |
} | |
function mkr_is_last_post( $query = false ) { | |
if ( ! $query ) { | |
global $wp_query; | |
$query = $wp_query; | |
} | |
return ( $query->current_post + 1 ) == $query->post_count; | |
} | |
function get_date_field( $format, $key, $id = false ) { | |
$date = get_field( $key, $id ); | |
return date_i18n( $format, strtotime( $date ) ); | |
} | |
function the_date_field( $format, $key, $id = false ) { | |
echo get_date_field( $format, $key, $id ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment