如何在wordpress中创建While Loop Post

时间:2016-10-25 13:45:02

标签: php wordpress

有没有人尝试过这个,因为我遇到了问题。

我有两个文件,一个是index.php,另一个是来自我的wordpress文件的content.php。我想要一个设计,左边显示帖子,右边显示另一个。这是代码

 code from my index.php --- 


        <?php if (have_posts()): ?><?php
        //loop through posts
        $position = 1;
        while (have_posts()):
            ?>
            <?php the_post(); ?>

            <?php get_template_part('content', _thrive_get_post_content_template($options)); ?>

            <?php if (thrive_check_blog_focus_area($position)): ?>
                <?php if (strpos($options['blog_layout'], 'masonry') === FALSE && strpos($options['blog_layout'], 'grid') === FALSE): ?>
                    <?php thrive_render_top_focus_area("between_posts", $position); ?>
                    <div class="spr"></div>
                <?php endif; ?>
            <?php endif; ?>

            <?php
            $position++;
        endwhile;
        ?>

虽然这是我的content.php代码的第二面

<li class="post <?php $array = array( "post-r", "post-l"); foreach( $array as $value ) {echo "$value";} ?> post-single">
<?php tha_entry_top(); ?>
<?php if ($options['featured_image_style'] == "wide" && $featured_image && $post_format != 'gallery' && $post_format != 'video'): ?>
<a href="<?php the_permalink(); ?>"> 
        <img class="lazy" data-orginal="<?php echo $featured_image; ?>" width="460" height="277" src="<?php echo $featured_image; ?>" alt="<?php echo $featured_image_alt; ?>" title="<?php echo $featured_image_title; ?>" style="display:block;">
        <noscript>&lt;img src="<?php echo $featured_image; ?>" width="460" height="277" alt="<?php the_title(); ?>"&gt;</noscript>
    <?php endif; ?>

    <h2 class="title"><?php the_title(); ?></h2>

    <?php if (isset($options['display_meta']) && $options['display_meta'] == 1): ?>
    <div class="details">
    <?php if (isset($options['meta_post_date']) && $options['meta_post_date'] == 1): ?>
    <p class="date"><?php echo $post_date; ?></p> <?php endif; ?>
    <p class="shares-comments">
    <span class="shares">278 shares</span>

    <span class="comments"><?php if ($options['meta_comment_count'] != 1 || get_comments_number() == 0): ?><?php echo get_comments_number(); ?><?php endif; ?> comments</span>

    </p>
    </div>
    <?php endif; ?>

我试图让博客帖子列表在两个不同的位置设置样式,“post-r”在右边,“post-l”在左边。有帮助吗?

0 个答案:

没有答案