</span>
					<?php 
                }
            }
            ?>

			</td></tr></tbody></table>
		<?php 
        }
        ?>

		<div class="vegetables-meta">
			<?php 
        $type = get_field('type');
        if ($type) {
            echo igarashi_nouen_get_type_label($type);
        }
        $season = get_field('season');
        if ($season) {
            echo igarashi_nouen_get_season_label($season);
        }
        ?>
		</div>

	</article>

<?php 
    }
}
?>
Beispiel #2
0
function igarashi_nouen_vegetables_calendar($atts)
{
    extract(shortcode_atts(array('title' => 'no'), $atts));
    $html_table_header = '<table class="vegetables-calendar"><tbody><tr><th class="title">&nbsp;</th><th class="data"><span>1月</span><span>2月</span><span>3月</span><span>4月</span><span>5月</span><span>6月</span><span>7月</span><span>8月</span><span>9月</span><span>10月</span><span>11月</span><span>12月</span></th></tr>';
    $html_table_footer = '</tbody></table>';
    $html = '';
    $args = array('posts_per_page' => -1, 'post_type' => 'vegetables', 'post_status' => 'publish', 'meta_key' => 'type', 'orderby' => 'meta_value');
    $the_query = new WP_Query($args);
    $type_current = '';
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $type = get_field('type');
            if ($type && $type != $type_current) {
                if (!empty($html)) {
                    $html .= $html_table_footer;
                }
                $html .= '<div class="vegetables-meta">' . igarashi_nouen_get_type_label($type) . '</div>';
                $type_current = $type;
                $html .= $html_table_header;
            }
            // 収穫カレンダー
            $selected = get_field('calendar');
            $html .= '<tr>';
            $html .= '<td class="title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></td>';
            $html .= '<td class="data">';
            for ($i = 1; $i <= 12; $i++) {
                if (in_array($i, $selected)) {
                    $html .= '<span class="best">' . $i . '</span>';
                } else {
                    $html .= '<span>' . $i . '</span>';
                }
            }
            $html .= '</td>';
            $html .= '</tr>';
        }
        wp_reset_postdata();
    }
    if (!empty($html)) {
        $html .= $html_table_footer;
    }
    if ('yes' === $title) {
        $html = '<h2>野菜収穫カレンダー</h2>' . $html;
    }
    return $html;
}
<?php

get_header();
?>

<div id="content">
	<div class="container">

		<article class="hentry">
			<header class="content-header">
				<h1 class="content-title">
				<?php 
$title = '';
$type = get_query_var('type');
if (!empty($type)) {
    $title = igarashi_nouen_get_type_label($type, FALSE);
    echo $title;
} else {
    if (!empty($season)) {
        $season = get_query_var('season');
        $title = igarashi_nouen_get_season_label($season, FALSE);
        echo $title . 'の野菜';
    }
}
if (empty($title)) {
    echo esc_html(get_post_type_object('vegetables')->label);
}
?>
				</h1>
			</header>