如何在wordpress中查看div
how to look through divs in wordpress
我能够遍历数据库并获得我想要的结果。但是,结果的显示方式正是我想要实现的。这是在 wordpress 中显示我从数据库中得到的结果的代码
result of the page when i implemented the code below
This what i really want to achieve
<?php $loop = new WP_Query(array('post_type' => 'education_detail', 'orderby' => 'post_id', 'order' => 'ASC'));?>
<?php while($loop->have_posts()) : $loop->the_post();?>
<div class="resume">
<ul class="timeline">
<li class="timeline timeline-inverted">
<div class="posted-date">
<span class="month"><?php the_field('resume_year')?></span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3><?php the_field('school_name')?></h3>
<span><?php the_field('course_study')?></span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p><?php the_field('course_description')?></p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div><!-- /timeline-panel -->
</li>
</ul>
</div>
<?php endwhile;?>
不过,这是同一网站 html 版本的代码
<ul class="timeline">
<li>
<div class="posted-date">
<span class="month">2007-2011</span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3>Bachelor degree certificate</h3>
<span>BA(Hons) in UI Engineering, Arts University, Pabna, USA</span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p>I have completed UI Engineering degree from ABC University, Boston, USA at feel the charm of existence in this spot, which was creat.</p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div><!-- /timeline-panel -->
</li>
<li class="timeline-inverted">
<div class="posted-date">
<span class="month">2004-2006</span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3>Higher Secondary certificate</h3>
<span>Typography Arts, FA College, New York, USA</span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p>From this college of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend.</p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div> <!-- /timeline-panel -->
</li>
我的问题是如何在我的 WordPress 版本中实现第二个 class,以便我可以拥有与我的 HTML
相同的界面
你需要做一个计数器来检查你的post是奇数还是偶数。
当你有你的计数器时,你会做一些 if 来检查 post 是偶数还是奇数,当它是奇数时你添加一个 class.
<?php while($loop->have_posts()) : $loop->the_post();?>
<div class="resume">
<ul class="timeline">
<?php
$postcount++;
if(($postcount % 2) == 0 ){
echo '<li class="timeline">';
}else{
echo '<li class="timeline-inverted">';
}
?>
<div class="posted-date">
<span class="month"><?php the_field('resume_year')?></span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3><?php the_field('school_name')?></h3>
<span><?php the_field('course_study')?></span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p><?php the_field('course_description')?></p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div><!-- /timeline-panel -->
</li>
</ul>
</div>
<?php endwhile;?>
也许是这样的。
我能够遍历数据库并获得我想要的结果。但是,结果的显示方式正是我想要实现的。这是在 wordpress 中显示我从数据库中得到的结果的代码 result of the page when i implemented the code below This what i really want to achieve
<?php $loop = new WP_Query(array('post_type' => 'education_detail', 'orderby' => 'post_id', 'order' => 'ASC'));?>
<?php while($loop->have_posts()) : $loop->the_post();?>
<div class="resume">
<ul class="timeline">
<li class="timeline timeline-inverted">
<div class="posted-date">
<span class="month"><?php the_field('resume_year')?></span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3><?php the_field('school_name')?></h3>
<span><?php the_field('course_study')?></span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p><?php the_field('course_description')?></p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div><!-- /timeline-panel -->
</li>
</ul>
</div>
<?php endwhile;?>
不过,这是同一网站 html 版本的代码
<ul class="timeline">
<li>
<div class="posted-date">
<span class="month">2007-2011</span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3>Bachelor degree certificate</h3>
<span>BA(Hons) in UI Engineering, Arts University, Pabna, USA</span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p>I have completed UI Engineering degree from ABC University, Boston, USA at feel the charm of existence in this spot, which was creat.</p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div><!-- /timeline-panel -->
</li>
<li class="timeline-inverted">
<div class="posted-date">
<span class="month">2004-2006</span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3>Higher Secondary certificate</h3>
<span>Typography Arts, FA College, New York, USA</span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p>From this college of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend.</p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div> <!-- /timeline-panel -->
</li>
我的问题是如何在我的 WordPress 版本中实现第二个 class,以便我可以拥有与我的 HTML
相同的界面你需要做一个计数器来检查你的post是奇数还是偶数。 当你有你的计数器时,你会做一些 if 来检查 post 是偶数还是奇数,当它是奇数时你添加一个 class.
<?php while($loop->have_posts()) : $loop->the_post();?>
<div class="resume">
<ul class="timeline">
<?php
$postcount++;
if(($postcount % 2) == 0 ){
echo '<li class="timeline">';
}else{
echo '<li class="timeline-inverted">';
}
?>
<div class="posted-date">
<span class="month"><?php the_field('resume_year')?></span>
</div><!-- /posted-date -->
<div class="timeline-panel wow fadeInUp">
<div class="timeline-content">
<div class="timeline-heading">
<h3><?php the_field('school_name')?></h3>
<span><?php the_field('course_study')?></span>
</div><!-- /timeline-heading -->
<div class="timeline-body">
<p><?php the_field('course_description')?></p>
</div><!-- /timeline-body -->
</div> <!-- /timeline-content -->
</div><!-- /timeline-panel -->
</li>
</ul>
</div>
<?php endwhile;?>
也许是这样的。