Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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 我正在尝试将我的日期和评论计数包含在循环中_Php_Loops - Fatal编程技术网

Php 我正在尝试将我的日期和评论计数包含在循环中

Php 我正在尝试将我的日期和评论计数包含在循环中,php,loops,Php,Loops,我正在创建我的第一个wordpress主题(也是第一次真正使用wordpress) 我试图将我的日期和评论数包含在循环中,尽管我在侧边栏的左侧有它,但我不知道如何包含它 这是我的帖子代码(它包括日期、评论数和按顺序发布的帖子,目前帖子只是循环的一部分): (我使用的是960网格,因此您可以在下面看到网格类) 六羟甲基三聚氰胺六甲醚?不可能。找到。邮递 下面是我在测试中将循环移动到代码中日期以上时发生的情况: 检查员说,在第一个grid_10类中,日期和评论数低于帖子: 这是我完成的主题

我正在创建我的第一个wordpress主题(也是第一次真正使用wordpress)

我试图将我的日期和评论数包含在循环中,尽管我在侧边栏的左侧有它,但我不知道如何包含它

这是我的帖子代码(它包括日期、评论数和按顺序发布的帖子,目前帖子只是循环的一部分):

(我使用的是960网格,因此您可以在下面看到网格类)


六羟甲基三聚氰胺六甲醚?不可能。找到。邮递

下面是我在测试中将循环移动到代码中日期以上时发生的情况:

检查员说,在第一个grid_10类中,日期和评论数低于帖子:


这是我完成的主题应该是什么样子 您可以在查看我正在进行的工作(只有帖子在循环中,上面的屏幕截图是我移动循环代码时发生的测试/示例)


要获取发布日期和时间,请使用此

<?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>
at
要获取注释计数,请使用以下命令

 <?php comments_number('No reply', '1 reply', '% replies'); ?>

放置在循环中的任意位置


参考:http://codex.wordpress.org/Function_Reference/comments_number要获取发布日期和时间,请使用此

<?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="grid_2">
    <div class="date_banner">
            <div class="d"><!-- sidebar 1 --><?php the_time('d'); ?></div>
            <div class="m"><!-- sidebar 1 --><?php the_time('M'); ?></div>
            <div class="y"><!-- sidebar 1 --><?php the_time('Y'); ?></div>
        </div>
        <div class="commentsnumber">
        <?php comments_number('No comment', '1 comment', '% comments'); ?>
        </div>
    </div>
    <!-- post -->
    <div class="grid_10 post">
        <div class="titlepostauthorimage">
            <div class="post-title">
                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
            </div>
            <div class="post-author-image">

            </div>
            <div class="post-author">
                 <?php the_author_posts_link(); ?>
            </div>
            <div class="post-image">
                <?php the_post_thumbnail( $size, $attr ); ?> 
            </div>
        </div>
        <div class="post-bodyborder">
            <div class="post-body">
                <?php the_content(); ?>
            </div>
        </div>
        <div class="post-metaborder">
            <div class="post-meta">
                <?php the_category(', '); ?>
                <!-- post tags -->
            </div>
        </div>
        <div class="post-comments">
        <?php wp_list_comments( $args ); ?> 
        </div>
    </div>
    <!-- post -->
<?php endwhile; else: ?>
    <!-- In case no posts were found -->
    <h1>Hmmm? Cam't. Find. Post.</h1>
<?php endif; ?>
at
要获取注释计数,请使用以下命令

 <?php comments_number('No reply', '1 reply', '% replies'); ?>

放置在循环中的任意位置

参考:http://codex.wordpress.org/Function_Reference/comments_number


<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="grid_2">
    <div class="date_banner">
            <div class="d"><!-- sidebar 1 --><?php the_time('d'); ?></div>
            <div class="m"><!-- sidebar 1 --><?php the_time('M'); ?></div>
            <div class="y"><!-- sidebar 1 --><?php the_time('Y'); ?></div>
        </div>
        <div class="commentsnumber">
        <?php comments_number('No comment', '1 comment', '% comments'); ?>
        </div>
    </div>
    <!-- post -->
    <div class="grid_10 post">
        <div class="titlepostauthorimage">
            <div class="post-title">
                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
            </div>
            <div class="post-author-image">

            </div>
            <div class="post-author">
                 <?php the_author_posts_link(); ?>
            </div>
            <div class="post-image">
                <?php the_post_thumbnail( $size, $attr ); ?> 
            </div>
        </div>
        <div class="post-bodyborder">
            <div class="post-body">
                <?php the_content(); ?>
            </div>
        </div>
        <div class="post-metaborder">
            <div class="post-meta">
                <?php the_category(', '); ?>
                <!-- post tags -->
            </div>
        </div>
        <div class="post-comments">
        <?php wp_list_comments( $args ); ?> 
        </div>
    </div>
    <!-- post -->
<?php endwhile; else: ?>
    <!-- In case no posts were found -->
    <h1>Hmmm? Cam't. Find. Post.</h1>
<?php endif; ?>
六羟甲基三聚氰胺六甲醚?不可能。找到。邮递

六羟甲基三聚氰胺六甲醚?不可能。找到。邮递

它可能是这样的(只是伪代码)


日期横幅html放在这里
PostHTML放在这里
六羟甲基三聚氰胺六甲醚?不可能。找到。邮递

它可能是这样的(只是伪代码)


日期横幅html放在这里
PostHTML放在这里
六羟甲基三聚氰胺六甲醚?不可能。找到。邮递

我已经有了日期和评论计数的代码,但我需要在不改变主题布局的情况下加入循环!谢谢,我已经有了日期和评论计数的代码,但是我需要在不改变主题布局的情况下加入循环!谢谢我只需要修复布局部分现在我只需要修复布局部分现在检查一下,我只是有一个布局的小问题现在我只是有我的右侧栏不在正确的位置issue@benlevywebdesign最好的做法是为每个问题提出一个新问题。然而,问题似乎出在网格上。您正在关闭
grid_16
,然后在
grid_16
中包含边栏,而不是包含边栏。将边栏添加到
grid_16
的顶部,并将其向右浮动。现在查看它,我只是有一个小问题,布局现在我只是有我的右侧栏没有在正确的位置issue@benlevywebdesign最好的做法是为每个问题提出一个新问题。然而,问题似乎出在网格上。您正在关闭
grid_16
,然后在
grid_16
中包括侧栏而不是侧栏,将侧栏添加到
grid_16
的顶部,并将其向右浮动。