Tag.php分页转到索引而不是分页2

时间:2019-01-14 10:19:19

标签: wordpress

我可以在其他.php中使用此分页代码,但对于tag.php,它可以返回到index.php,请问我知道问题背后的原因...

我知道,如果您尝试访问的页面不存在,它将引导您返回index.php

之前:

nyov’s approach

单击分页后。

http://localhost/wordpress/tag/monster/

   <?php

    $paged = (get_query_var('page')) ? get_query_var('page') : 1;
    $wp_query = new WP_Query();
    $wp_query->query('tag=monster&posts_per_page=3&paged=' . $paged );



            $list = '<div class="wrapper" >';  

            while ( $wp_query->have_posts() ) : $wp_query->the_post();

                echo "<div class='box' >";

                    //PICTURES
                    if ( has_post_thumbnail() ) {
                            echo "<center><div class='tag-cat'>".wp_get_attachment_image(get_post_thumbnail_id(),'post-thumbnail') ."</div></center>";

                    } 
                    //              
                    echo "<center><div class='first-label'>";
                        //$post_tags = get_the_tags();
                        //if(!empty($post_tags)){
                        //  foreach($post_tags as $tag){
                        //      echo  trim($tag->name) . ", ";
                        //  }
                        //}
                        $category = get_the_category(); 
                        if(!empty($category)){
                            foreach($category as $cat){
                                echo  trim($cat->name);

                                if (end($category) != $cat){
                                    echo  ", ";
                                }else{
                                    echo  " / ";
                                }



                            }
                        }
                        echo get_the_time('F j, Y'); 
                    echo "</div></center>";

                    echo "<center><div class='tag-cats'>";
                        echo "<h2><a href='".get_the_permalink()."'>".get_the_title()."</a></h2>";
                    echo "</div></center>";

                    echo "<div class='post-pl'>";
                        $content = get_the_content();   
                        $postcontent = substr($content, 0, 93); 
                        echo $postcontent . "...";
                    echo "</div>";

                    echo "<center><div class='readmore'><a href='".get_the_permalink()."'>READ MORE</a></div><center>";


                echo "</div>";

            endwhile;

            echo "</div>";          
                      the_posts_pagination( array(
                                                                    'mid_size' => 3,
                                                                    'prev_text' => __( 'PREVIOUS', 'findarch' ),
                                                                    'next_text' => __( 'NEXT', 'findarch' ),
                                                                    'screen_reader_text'    => __('navigation','findarch'))). wp_reset_query();
    ?>

0 个答案:

没有答案