Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 环绕分组的循环开始处的空结束div_Php_Wordpress_While Loop - Fatal编程技术网

Php 环绕分组的循环开始处的空结束div

Php 环绕分组的循环开始处的空结束div,php,wordpress,while-loop,Php,Wordpress,While Loop,我甚至不知道要寻找什么,所以自从我被难倒以来,我尝试的并不多 这是一个循环,获取月份名称,然后将该月份内的事件分组。注释//*关闭Div:问题在于问题所在。代码执行它应该执行的操作,但是列表前有一个空div if ( have_posts() ) : $current_month = ''; while ( have_posts() ) : the_post(); if( $current_month != eo_get_the_start( '

我甚至不知道要寻找什么,所以自从我被难倒以来,我尝试的并不多

这是一个循环,获取月份名称,然后将该月份内的事件分组。注释
//*关闭Div:
问题在于问题所在。代码执行它应该执行的操作,但是列表前有一个空div

if ( have_posts() ) : 

    $current_month = '';

    while ( have_posts() ) : the_post();


            if( $current_month != eo_get_the_start( 'm' ) ) :

                    $month = eo_get_the_start('F Y');

                    //* Close the Div : PROBLEM this is where it echos an empty closing div before first month name
                    echo '</div><!-- /events-by-month -->'; 

                    //* Start new group
                    echo '<h3 class="event-month" id="'. $month . '">' . $month . '</h3>';

                    //* Open div around the events in this month
                    echo '<div class="events-by-month" style="border:1px solid green">'; //* inline style so I can see

            endif;

                $current_month = eo_get_the_start('m');

                eo_get_template_part( 'eo-loop-single-event' );


    endwhile;


    //* Genesis Numbered Pagination
    genesis_numeric_posts_nav();

    else:

        echo '<p>'. __( 'No Events', 'joyful' ) . '</p>';

endif;
if(have_posts()):
$current_month='';
while(have_posts()):the_post();
如果($current\u month!=eo\u获得开始('m'):
$month=eo_获得_开始('fy');
//*关闭Div:问题是它在第一个月名称之前回显一个空的结束Div
回声';
//*创建新组
回显“”$月",;
//*打开本月活动的div
回显“”;//*内联样式,以便我可以看到
endif;
$current_month=eo_获取_开始('m');
eo_获取_模板_部分(“eo循环单事件”);
结束时;
//*数字分页
genesis_numeric_posts_nav();
其他:
回音“”__(“无事件”、“快乐”)

",; endif;
您的while循环将首先循环一次,并在回显初始开始标记之前回显结束标记

只要检查$current_month是否为空,就可以解决这个问题


回声!空($当前月)?“”:无效

回声怎么样!空($当前月)?“”:无效@lawrencerone-Hm…,我开始怀疑我发布的答案是否应该删除。编辑:我把它删除了,我的错。如果@lawrencerone在评论中发布的内容解决了这个问题,那么让他知道是否要将这个问题标记为已解决。早些时候我错了,这是我的疏忽。@Fred ii-请在你的答案中加上它;p(如果我是对的,希望我们不会被绞死)@lawrencerone谢谢Lawrence,但这不公平。你去吧;-)这都是你的。“通常我对wordpress相关的东西是错的”-好吧,这次不是。谢谢。你没有错。我觉得自己像个哑巴,但又一次,我走出了我的舒适区。我必须这样做,以便风格,我只是想忘记它,只是包装在jQuery中,本来可以这样做,然后我可以继续,但它困扰着我。没问题,很高兴能提供帮助。