Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.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)_Php_Wordpress_While Loop - Fatal编程技术网

Php 在主页中循环帖子类别后出现问题(wordpress)

Php 在主页中循环帖子类别后出现问题(wordpress),php,wordpress,while-loop,Php,Wordpress,While Loop,我的主页上有两个部分,如下所示: <section class="tours" id="tours"> <div class="container-fluid"> <h2><?php the_field('tours_title'); ?></h2> <div class="row"> <?php

我的主页上有两个部分,如下所示:

<section class="tours" id="tours">
            <div class="container-fluid">
                <h2><?php the_field('tours_title'); ?></h2>
                <div class="row">
                <?php
                    global $post; // needed this

                    $temp = $wp_query; $wp_query= null;
                    $wp_query = new WP_Query(); $wp_query->query('cat=3' . '&showposts=5' . '&paged='.$paged);
                    if($wp_query->have_posts()): ?>

                        <?php while ($wp_query->have_posts()) : $wp_query->the_post(); 
                        // get the latest blog entry
                        $img_id = get_post_thumbnail_id(get_the_ID());
                        $alt_text = get_post_meta($img_id , '_wp_attachment_image_alt', true); ?>
                        <div class="col20">
                            <div class="tour-img">
                                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                            </div>
                            <div class="tour-desc">
                                <h3><?php the_title(); ?></h3>
                                <p><?php the_field('short_description'); ?></p>
                            </div>
                        </div>
                        <?php endwhile; 
                endif; ?>

                </div>
            </div>
            <div class="tours-bg">                  
                <video autoplay loop>
                    <source src="<?php bloginfo('stylesheet_directory'); ?>/images/file1.mp4" type="video/mp4">
                </video>
                <div class="tours-overlay"></div>
            </div>
        </section>      
        <section class="about" id="about">
            <div class="about-content">
                <h2><?php the_field('about_title'); ?></h2>
                <p><?php the_content(); ?></p>
            </div>
            <div class="about-bg">                  
                <video class="bv-video" autoplay loop></video>
            </div>
        </section>  


尝试使用echo$content=get_post_字段('post_content',$page_id);并检查它是否解决了问题。

在自定义循环后添加
,以将$wp\u查询和全局post数据恢复到原始主查询


参考资料:

这里$page\u id将是你的主页,我是php的乞丐,我不知道在哪里可以使用它。我知道该查询会对页面的其余部分产生不良影响。请将

更改为:-