Esempio n. 1
0
$country = get_page_by_path($country_slug, OBJECT, 'country');
$country_id = $country->ID;
$residents_id = get_page_by_path('residents')->ID;
$residents_url = get_permalink($residents_id);
$country_query = array('key' => 'country', 'value' => '"' . $country_id . '"', 'compare' => 'LIKE');
$residents_query = array('post_type' => 'resident', 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_key' => 'residency_dates_0_start_date', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_query' => array($country_query));
$residents = new WP_Query($residents_query);
$GLOBALS['wp_query'] = $residents;
if (have_posts()) {
    while (have_posts()) {
        the_post();
        global $post;
        $id = $post->ID;
        $name = $post->post_title;
        $url = get_permalink($id);
        $end_date = new DateTime(get_resident_end_date($id));
        $year = $end_date->format('Y');
        $year_url = $residents_url . '?filter=all&date=' . $year;
        $year = '<a href="' . $year_url . '">' . $year . '</a>';
        $bio = get_field('bio', $resident_id);
        echo '<div class="row shelf-item resident">';
        echo '<div class="inner">';
        echo '<div class="value name">';
        if ($bio) {
            echo '<a href="' . $url . '">';
            echo $name;
            echo '</a>';
        } else {
            echo $name;
        }
        echo '</div>';
Esempio n. 2
0
$url = get_permalink();
if ($bio) {
    if (have_rows('residency_dates', $resident_id)) {
        while (have_rows('residency_dates')) {
            the_row();
            $start_date_dt = new DateTime(get_sub_field('start_date', $resident_id));
            $start_date = $start_date_dt->format('M j, Y');
            $end_date_dt = new DateTime(get_sub_field('end_date', $resident_id));
            $end_date = $end_date_dt->format('M j, Y');
            $start_year = $start_date_dt->format('Y');
            $end_year = $end_date_dt->format('Y');
        }
    }
} else {
    $no_link = 'nolink';
    $end_date_dt = new DateTime(get_resident_end_date($resident_id));
    $end_year = $end_date_dt->format('Y');
}
$thumb = get_thumb($resident_id);
echo '<div class="resident item shelf-item border-bottom ' . $resident_status . ' ' . $no_link . '"><div class="inner">';
if ($bio) {
    echo '<a class="wrap value name" href="' . $url . '">';
}
echo '<h2 class="link title name">' . $title . '</h2>';
echo '<div class="image">';
if ($bio && $thumb) {
    echo '<img src="' . $thumb . '"/>';
}
echo '</div>';
if ($bio) {
    echo '</a>';
Esempio n. 3
0
function is_past($id)
{
    $today = new DateTime();
    $today = $today->format('Ymd');
    $resident = get_post($id);
    $end_date = get_resident_end_date($id);
    if ($end_date) {
        if ($end_date < $today) {
            return true;
        } else {
            return false;
        }
    }
}