0
我在WordPress中建立一個頁面,它使用兩個高級自定義形式中繼器,並在他們之間的頁面插入模板部分。如果get_template_part()調用在兩個中繼器之後,所有內容都可以正常加載,但是當它位於兩個中繼器之間時,get_template_part()之後的內容不會加載,我不知道爲什麼。WordPress的get_template_part()打破先進的自定義形式中繼器
<?php get_header(); ?>
<div class="clearfix" role="main" >
<?php if(get_field('landing')):?>
<?php while (have_rows('landing')) : the_row(); ?>
<section class="block row" id="landing" style="background-image: url('<?php the_sub_field('background'); ?>');">
<div class="text-center">
<img src="<?php the_sub_field('image'); ?>" />
<p class=""><?php echo the_sub_field('text'); ?></p>
<a class="" href="<?php the_sub_field('section_url');?>"><?php the_sub_field('url_text'); ?></a>
<a href="#" class="text-center"><img src="<?php bloginfo('template_directory');?>/images/more_icon.png"></img></a>
</div>
</section> <!-- end article header -->
<?php endwhile; ?>
<?php endif; ?>
<?php get_template_part ('social');?>
<?php if(get_field('section')):?>
<?php while (have_rows('section')) : the_row(); ?>
<section class="block row" style="background-image: url('<?php the_sub_field('background'); ?>');">
<div class="text-center">
<img src="<?php the_sub_field('image'); ?>" />
<p class=""><?php echo the_sub_field('text'); ?></p>
<a class="" href="<?php the_sub_field('section_url');?>"><?php the_sub_field('url_text'); ?></a>
<a href="#" class="text-center"><img src="<?php bloginfo('template_directory');?>/images/more_icon.png"></img></a>
</div>
</section> <!-- end article header -->
<?php endwhile; ?>
<?php endif; ?>
</div> <!-- end #content -->
下面是get_template_part()調用的代碼:
<div class="row block">
<div class="col-sm-3">
<h3>Instagram</h3>
<p>This is an instagram feed</p>
</div>
<div class="col-sm-3">
<h3>On The Radio</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap</p>
</div>
<div class="col-sm-3">
<h3>In The News</h3>
<p><?php
global $post;
$args = array('posts_per_page' => 3);
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post); ?>
<a href="<?php the_permalink() ?>" class="pull-right" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?><br />
<?php echo get_the_date(); ?></a>
<?php the_post_thumbnail(); ?>
<?php endforeach; ?></p>
</div>
<div class="col-sm-3">
<div class="text-center"><img src="<?php bloginfo('template_directory');?>/images/reclamation_road.png"/></div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum has been the industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap</p>
</div>
我不知道是什麼問題。任何幫助將不勝感激。
真棒,工作像一個魅力。 – 2014-09-06 18:23:46
很高興工作。如果它對你有幫助,請隨時接受答案。 – 2014-09-06 18:33:11
WWWWwwwhhhyyyyyy?!?! (謝謝) – CenterOrbit 2015-08-07 23:21:13