Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WordPress get_template_part()中断高级自定义表单重复程序_Php_Html_Wordpress - Fatal编程技术网

Php WordPress get_template_part()中断高级自定义表单重复程序

Php WordPress get_template_part()中断高级自定义表单重复程序,php,html,wordpress,Php,Html,Wordpress,我正在WordPress中构建一个页面,它使用两个高级自定义表单转发器,并在它们之间的页面中插入一个模板部分。如果get\u template\u part()调用在两个转发器之后,所有内容都会加载,但是当它位于两个转发器之间时,get\u template\u part()之后的内容不会加载,我不确定原因 <?php get_header(); ?> <div class="clearfix" role="main" > <?php if(get

我正在WordPress中构建一个页面,它使用两个高级自定义表单转发器,并在它们之间的页面中插入一个模板部分。如果get\u template\u part()调用在两个转发器之后,所有内容都会加载,但是当它位于两个转发器之间时,get\u template\u 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 -->


发生这种情况是因为在模板部分social中,您使用的是
setup\u postdata()
,它覆盖了当前的
$post


因此,您必须将
$post
重置为原始设置。为此,在
endforeach
之后,应该调用
wp\u reset\u postdata()
。有关更多信息和示例用法,请参阅:

很高兴它起作用。如果答案对你有帮助,请随意接受。
<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>