如何在wordpress中查看div

时间:2016-07-10 19:20:57

标签: php wordpress wordpress-theming

我能够遍历数据库并获得我想要的结果。但是,结果的显示方式是我想要实现的。这是在wordpress中显示我的DB结果的代码 result of the page when i implemented the code below This what i really want to achieve

install.packages("coefplot2", # from this crackpot R coder named Bolker
                 repos="http://www.math.mcmaster.ca/bolker/R",
                 type="source") # I think he died a few years back
                                # jk Ben
library(coefplot2)
coefplot2(m1)
ggplot(tmp, aes(x = Comparison, y = Estimate, ymin = lwr, ymax = upr)) + geom_errorbar() + geom_point()

Nevertheles,这是同一网站的html版本的代码

<?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;?>

我的问题是如何在我的WordPress版本中实现第二类,以便我可以拥有与HTML相同的界面

1 个答案:

答案 0 :(得分:0)

你需要制作一个计数器来检查你的帖子是奇数还是偶数。 当你有你的计数器时,你会做一点点检查这个帖子是偶数还是奇数,当它奇怪你添加一个类时。

<?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;?>

这样的事可能。