我想实现图像中的内容:
我目前所拥有的是:
我实际上已经完成了,但是我无法弄清楚的是如何使同月的帖子填充到col-10
div中,而当我们转到另一组不同月份的帖子时,应重新引入<div class='tax-calendar-container container'><div class='row'>
div,以便每个月都放在不同的容器中,以便它们正确堆叠。
当每月只有一个帖子,但有2个或更多帖子时,它会起作用,第一个显示应发布的位置,其余则单独显示。
任何想法都应该添加什么逻辑以进行预期的更改?
function taxCalendar()
{
$current_url = $_SERVER['REQUEST_URI'];
$count = 0;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if(get_locale() == 'en_US') {
$wpb_all_query = new WP_Query(array('post_type' => 'post', 'category_name' => 'Tax Calendar', 'post_status' => 'future', 'posts_per_page' => 6, 'paged' => $paged));
} else {
$wpb_all_query = new WP_Query(array('post_type' => 'post', 'category_name' => 'Tax Calendar AR', 'post_status' => 'future', 'posts_per_page' => 6, 'paged' => $paged));
}
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if($wpb_all_query->have_posts()) :
while($wpb_all_query->have_posts()) :
if(isset($postmonth)) {
$prevmonth = $postmonth;
}
$wpb_all_query->the_post();
$current_ID = get_the_ID();
$postday = get_the_date('d', $current_ID);
$postmonth = get_the_date('M', $current_ID);
$postyear = get_the_date('Y', $current_ID);
$postcontent = get_the_content($current_ID);
if($postmonth == 'Jan') {
$postmonthnumber = 1;
}
if($postmonth == 'Feb') {
$postmonthnumber = 2;
}
if($postmonth == 'Mar') {
$postmonthnumber = 3;
}
if($postmonth == 'Apr') {
$postmonthnumber = 4;
}
if($postmonth == 'May') {
$postmonthnumber = 5;
}
if($postmonth == 'Jun') {
$postmonthnumber = 6;
}
if($postmonth == 'Jul') {
$postmonthnumber = 7;
}
if($postmonth == 'Aug') {
$postmonthnumber = 8;
}
if($postmonth == 'Sep') {
$postmonthnumber = 9;
}
if($postmonth == 'Oct') {
$postmonthnumber = 10;
}
if($postmonth == 'Nov') {
$postmonthnumber = 11;
}
if($postmonth == 'Dec') {
$postmonthnumber = 12;
}
if($postmonthnumber < 10) {
$postmonthnumber = "0" . "$postmonthnumber";
}
$fulldateofpost = "$postyear" . "-" . "$postmonthnumber" . "-" . "$postday";
echo "<div class='tax-calendar-container container'><div class='row'>";
echo "
<script>
$( document ).ready(function() {
$('#" . $fulldateofpost . "').addClass('active');
});
</script>
";
if(isset($prevmonth)) {
if($prevmonth == $postmonth) {
} else {
echo "
<div class='col-2'>"
. build_calendar($postmonthnumber, $postyear) . "
</div>";
}
} else {
echo "
<div class='col-2'>"
. build_calendar($postmonthnumber, $postyear) . "
</div>";
}
echo "
<div class='col-10'>
<div class='calendar-date'>
<span class='day-month'> $postmonth $postday</span>
<br>
<br>
$postcontent
<br><br>
</div>
</div>
";
echo "</div>";
echo "</div>";
endwhile;
else :
_e('Sorry, no posts matched your criteria.');
endif;
}
add_shortcode('taxCalendarList', 'taxCalendar');