为什么在添加自定义帖子类型后,社交图标徽章会消失?

时间:2017-06-23 作者:Daniel

我希望我的措辞正确,因为这个问题可能有点复杂。在使用ACF和CPT UI创建了一个快速链接部分后,我的社交图标功能消失了,而使用ACF创建的社交图标功能也从主页上消失了,尽管它仍然位于wp仪表板的主页上。enter image description here

enter image description here

社交图标徽章应该在版权线以上,它们就消失了。若你们看页脚。php:

<?php
/*
   Template Name: Home Page
*/
// Advanced Custom Fields
       $quick_links_title   = get_field(\'quick_links_title\');

get_header(); ?>

   <?php get_template_part(\'content\',\'hero\'); ?>

   <?php get_template_part(\'content\',\'donate\'); ?>

      <div class="container-fluid">
         <div class="row">
            <div class="col-md-8">
               <div class="panel panel-default">
                  <div class="panel-heading">
                     <h3 class="panel-title">Welcome to Three Green Birds!</h3>
                  </div><!-- panel-heading -->
                  <div class="panel-body">


                           <?php if (have_posts()) : ?>

                           <?php while (have_posts()) : the_post(); ?>


                              <!--<div class="spacer"></div>-->
                            <div class="post-title">
                     <?php if (function_exists(\'get_cat_icon\')) get_cat_icon(\'class=myicons\'); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
                              <div class="spacer"></div>
                              <div class="post-content">
                              <?php the_content(\'Read the rest of this entry &raquo;\'); ?>
                              </div>
                              <div class="spacer"></div>
                                 <div class="postmeta"><span class="postcat"><b>Categories:</b> <?php the_category(\', \') ?>
                                 <?php the_tags(\'| <b>Tags:</b> \', \', \', \'\'); ?>
                                 | <b>Comments:</b> <?php comments_popup_link(\'0\', \'1\', \'%\', \'\', \'Off\'); ?></span>
                               <span class="postcat"><?php edit_post_link(\'| <b>Edit</b>\'); ?></span>
                                 </div>    
                              <div class="post-footer"></div>

                              <?php endwhile; ?>

                           <div class="navigation">
                           <br/><br/>
                              <div class="alignleft"><?php next_posts_link(\'&laquo; Older Entries\') ?></div>
                              <div class="alignright"><?php previous_posts_link(\'Newer Entries &raquo;\') ?></div>
                           </div>

                        <?php else : ?>

                           <div class="post-title">Not Found</div>
                           <p class="post-content">Sorry, but you are looking for something that isn\'t here.</p>
                           <?php include (TEMPLATEPATH . "/searchform.php"); ?>

                        <?php endif; ?>


                        <!-- Quick Links
                        ======================================================== -->
                        <section id="quick-links">
                           <div class="container">
                              <h2><?php echo $quick_links_title; ?></h2>
                              <div class="row">

                                 <?php $loop = new WP_Query(array(\'post_type\' => \'quick_links\', \'orderby\' => \'post_id\', \'order\' => \'ASC\')); ?>
                                 <?php while($loop->have_posts()) : $loop->the_post(); ?>

                                 <div class="col-sm-3">

                                    <?php 

                                       if(has_post_thumbnail()) {
                                          the_post_thumbnail();
                                       }

                                    ?>

                                    <h3><?php the_title(); ?></h3></a>
                                    <p><?php the_content(); ?></p>
                                 </div><!-- end col -->
                                 <?php endwhile; ?>

                              </div><!-- row -->
                           </div><!-- container -->
                        </section><!-- quick-links -->

                  </div><!-- panel-body -->
               </div><!-- panel panel-default -->
            </div><!-- col-md-8 -->
            <!-- SIDEBAR 
               ====================================================================== -->
            <div class="col-md-4">
               <?php if (is_active_sidebar(\'sidebar\')) : ?>
                  <?php dynamic_sidebar(\'sidebar\'); ?>
               <?php endif; ?>
            </div><!-- col-md-4 -->
         </div><!-- row -->
      </div><!-- container-fluid -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>
它们都在那里,但为什么它们在浏览器中不可见呢。当我检查Chrome控制台时,col-lg-12的div内没有任何内容。

1 个回复
最合适的回答,由SO网友:Milo 整理而成

你需要wp_reset_postdata() 在二次查询上运行循环后。

使命感$loop->the_post(); 填充全局$post 使用该循环中的当前post数据。当你稍后打电话时get_field 在不显式提供post ID的情况下,它从$post, 这是您自定义查询中的最后一篇文章,而不是主页。

结束

相关推荐

为什么在添加自定义帖子类型后,社交图标徽章会消失? - 小码农CODE - 行之有效找到问题解决它

为什么在添加自定义帖子类型后,社交图标徽章会消失?

时间:2017-06-23 作者:Daniel

我希望我的措辞正确,因为这个问题可能有点复杂。在使用ACF和CPT UI创建了一个快速链接部分后,我的社交图标功能消失了,而使用ACF创建的社交图标功能也从主页上消失了,尽管它仍然位于wp仪表板的主页上。enter image description here

enter image description here

社交图标徽章应该在版权线以上,它们就消失了。若你们看页脚。php:

<?php
/*
   Template Name: Home Page
*/
// Advanced Custom Fields
       $quick_links_title   = get_field(\'quick_links_title\');

get_header(); ?>

   <?php get_template_part(\'content\',\'hero\'); ?>

   <?php get_template_part(\'content\',\'donate\'); ?>

      <div class="container-fluid">
         <div class="row">
            <div class="col-md-8">
               <div class="panel panel-default">
                  <div class="panel-heading">
                     <h3 class="panel-title">Welcome to Three Green Birds!</h3>
                  </div><!-- panel-heading -->
                  <div class="panel-body">


                           <?php if (have_posts()) : ?>

                           <?php while (have_posts()) : the_post(); ?>


                              <!--<div class="spacer"></div>-->
                            <div class="post-title">
                     <?php if (function_exists(\'get_cat_icon\')) get_cat_icon(\'class=myicons\'); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
                              <div class="spacer"></div>
                              <div class="post-content">
                              <?php the_content(\'Read the rest of this entry &raquo;\'); ?>
                              </div>
                              <div class="spacer"></div>
                                 <div class="postmeta"><span class="postcat"><b>Categories:</b> <?php the_category(\', \') ?>
                                 <?php the_tags(\'| <b>Tags:</b> \', \', \', \'\'); ?>
                                 | <b>Comments:</b> <?php comments_popup_link(\'0\', \'1\', \'%\', \'\', \'Off\'); ?></span>
                               <span class="postcat"><?php edit_post_link(\'| <b>Edit</b>\'); ?></span>
                                 </div>    
                              <div class="post-footer"></div>

                              <?php endwhile; ?>

                           <div class="navigation">
                           <br/><br/>
                              <div class="alignleft"><?php next_posts_link(\'&laquo; Older Entries\') ?></div>
                              <div class="alignright"><?php previous_posts_link(\'Newer Entries &raquo;\') ?></div>
                           </div>

                        <?php else : ?>

                           <div class="post-title">Not Found</div>
                           <p class="post-content">Sorry, but you are looking for something that isn\'t here.</p>
                           <?php include (TEMPLATEPATH . "/searchform.php"); ?>

                        <?php endif; ?>


                        <!-- Quick Links
                        ======================================================== -->
                        <section id="quick-links">
                           <div class="container">
                              <h2><?php echo $quick_links_title; ?></h2>
                              <div class="row">

                                 <?php $loop = new WP_Query(array(\'post_type\' => \'quick_links\', \'orderby\' => \'post_id\', \'order\' => \'ASC\')); ?>
                                 <?php while($loop->have_posts()) : $loop->the_post(); ?>

                                 <div class="col-sm-3">

                                    <?php 

                                       if(has_post_thumbnail()) {
                                          the_post_thumbnail();
                                       }

                                    ?>

                                    <h3><?php the_title(); ?></h3></a>
                                    <p><?php the_content(); ?></p>
                                 </div><!-- end col -->
                                 <?php endwhile; ?>

                              </div><!-- row -->
                           </div><!-- container -->
                        </section><!-- quick-links -->

                  </div><!-- panel-body -->
               </div><!-- panel panel-default -->
            </div><!-- col-md-8 -->
            <!-- SIDEBAR 
               ====================================================================== -->
            <div class="col-md-4">
               <?php if (is_active_sidebar(\'sidebar\')) : ?>
                  <?php dynamic_sidebar(\'sidebar\'); ?>
               <?php endif; ?>
            </div><!-- col-md-4 -->
         </div><!-- row -->
      </div><!-- container-fluid -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>
它们都在那里,但为什么它们在浏览器中不可见呢。当我检查Chrome控制台时,col-lg-12的div内没有任何内容。

1 个回复
最合适的回答,由SO网友:Milo 整理而成

你需要wp_reset_postdata() 在二次查询上运行循环后。

使命感$loop->the_post(); 填充全局$post 使用该循环中的当前post数据。当你稍后打电话时get_field 在不显式提供post ID的情况下,它从$post, 这是您自定义查询中的最后一篇文章,而不是主页。

相关推荐