Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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 字;数组";出现在博客帖子页面上_Php_Templates - Fatal编程技术网

Php 字;数组";出现在博客帖子页面上

Php 字;数组";出现在博客帖子页面上,php,templates,Php,Templates,当我使用下面的代码时,我的博客帖子页面上出现了“Array”一词。我觉得它与这一行有关: 我正在为我的公文包和新闻页面使用一个类似的模板,其中这一行的措辞略有不同(“showportcat”和“shownewscat”而不是“get_the_category”),它应该显示类别,但相反,“array”一词就在它的位置上 我试过“showpostcat”,但不起作用,所以我想知道是否需要重新措辞?或者问题出在我下面包含的代码的另一部分 <div class="greybloc

当我使用下面的代码时,我的博客帖子页面上出现了“Array”一词。我觉得它与这一行有关:

我正在为我的公文包和新闻页面使用一个类似的模板,其中这一行的措辞略有不同(“showportcat”和“shownewscat”而不是“get_the_category”),它应该显示类别,但相反,“array”一词就在它的位置上

我试过“showpostcat”,但不起作用,所以我想知道是否需要重新措辞?或者问题出在我下面包含的代码的另一部分

        <div class="greyblock">
            <h4 class="nomar"><?php echo the_title(); ?></h4>
            <div class="sep"></div>

                <?php echo get_the_category(get_the_ID()); ?>

                <div class="clear"></div>
                <ul class="blogpost_list columns2">

                <?php
                $temp = $wp_query;
                $wp_query = null;
                $wp_query = new WP_Query();
                $args = array(
                'post_type' => 'post',
                'paged' => $paged,
                'posts_per_page' => get_option("posts_per_page"),   
                );


                if (isset($_GET['slug'])) {
                $args['tax_query']=array( 
                        array( 
                            'taxonomy' => 'postcat',  
                            'field' => 'slug',  
                            'terms' => $_GET['slug']  
                         )
                    );
                }



                $wp_query->query($args);
                ?>
                <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); 
                #We have:
                #get_permalink() - Full url to post;
                #get_the_title() - Post title;
                #get_the_content() - Post text;
                #get_post_time('U', true) - unix timestamp

                $featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );   


                echo "
                <li class='pc'>
                        <img alt='".get_the_title()."' src='".TIMTHUMBURL."?w=400&h=400&src=".$featured_image[0]."'>
                        <h4>".get_the_title()."</h4>";
                        $terms = get_the_terms($post->ID, 'postcat');
                        if ( $terms && ! is_wp_error( $terms ) ) {

                        $draught_links = array();

                        foreach ( $terms as $term ) {
                            $draught_links[] = $term->name;
                        }

                        $on_draught = join( ", ", $draught_links );
                        }

                echo "
                <p>".get_the_excerpt()."</p>
                    <a href='".get_permalink()."' class='read'>Read more</a>                        
                    <br class='clear' />
                </li>
                ";  

                 endwhile; ?>

            </ul>
        </div>
        <?php get_pagination() ?>
        <?php $wp_query = null; $wp_query = $temp;  ?>   

    那么:

    $categories = get_the_category(get_the_ID());
    foreach ($categories as $category) {
        echo $category;
    }
    

    问题仍然存在。我猜这与我对以下两行中的一行的措辞有关,因为对公文包来说是“showportcat”,对新闻来说是“shownewscat”,但“showpostcat”对帖子不起作用,所以我无法理解:

     <?php echo get_the_category(get_the_ID()); ?>
     **OR**
     'taxonomy' => 'postcat', 
    
    
    **或**
    “分类法”=>“邮政编码”,
    
    var\u dump
    变量,以便查看实际使用的内容。