【发布时间】:2016-11-08 16:30:24
【问题描述】:
我一直在寻找一种解决方案来设置我的自定义帖子循环,如下所示:
first post> img left, content right // 第二个帖子> content left, img right
这是我目前的代码:
<div class="container">
<?php $loop = new WP_Query( array( 'post_type' => 'profile', 'posts_per_page' => 10 ) ); ?>
<?php if (have_posts()) : while(have_posts()) : the_post(); $i++; if(($i % 2) == 0) : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(''); ?> role="article" itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
<div class="row centered wow fadeInUpBig" data-wow-duration="2s">
<div class="col col-4">
<?php the_post_thumbnail(600); ?>
</div>
<div class="col col-6">
<section class="entry-content cf" itemprop="articleBody">
<span class="bold function"><?php echo get_the_term_list( $post->ID, 'Funktion', '', ', ', '' ); ?></span>
<h2 class="entry-title single-title" itemprop="headline" rel="bookmark"><?php the_title(); ?></h2>
<?php the_content();?>
</section>
</div>
</div>
</article>
<?php else : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(''); ?> role="article" itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
<div class="row centered wow fadeInUpBig" data-wow-duration="2s">
<div class="col col-6">
<section class="entry-content cf" itemprop="articleBody">
<span class="bold function"><?php echo get_the_term_list( $post->ID, 'Funktion', '', ', ', '' ); ?></span>
<h2 class="entry-title single-title" itemprop="headline" rel="bookmark"><?php the_title(); ?></h2>
<?php the_content();?>
</section>
</div>
<div class="col col-4">
<?php the_post_thumbnail(600); ?>
</div>
</div>
</article>
<?php endif; endwhile; endif; ?>
</div>
我知道,这个问题已经被问过好几次了,我已经尝试过this 和this 并且我读过this 但对我没有任何用处。我做错了什么?
【问题讨论】:
-
那么你现在的结果是什么?全部左对齐还是全部右对齐?
-
结果很奇怪。这个网站上已经添加了 3 个帖子,但我只得到了条目标题,但它没有给出帖子的条目标题,它会生成页面的条目标题(如果有任何意义的话)。跨度>
-
我已经得到了这个代码(没有改变):