将php文件链接到wordpress中的“查看所有”按钮


link php file to a view all button in wordpress

category.php页面中,我列出的帖子sub-categries,以及哪个子类别包含3个以上的帖子我将显示一个VIEW ALL按钮以转到view-all.php页面。在我的wordpress主题文件夹中,我有一个名为"view-all.php"的页面,可以查看特定子类别下的所有帖子。但我不明白如何用一些parameter将VIEW ALL按钮链接到view-all.php页面。请帮我提一下你的建议,因为我是文字出版社的初学者谢谢

这是category.php

<?php get_header(); ?>
<?php get_sidebar(); ?>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12">
<?php
// get category ID of particular category
$current_category = single_cat_title("", false);
$category_id = get_cat_ID($current_category);
// end getting category ID
// Get the name of sub-category
$categories =  get_categories('child_of='.$category_id);
foreach  ($categories as $category) {
// Display the sub category information using $category values like $category->cat_name
echo "<div class='sub-category-wrapper'>";
echo '<h3 class="sub-cat-name">&raquo; '.$category->name.'</h3>';
// get number of posts under this sub-category
$total_posts = $category->count;
// Make a loop to display post link which are in this sub category
foreach (get_posts( array(
'category' => $category->term_id,
'orderby' => 'date',
'order'   => 'DESC',
'numberposts' => 3,   // limit number of posts
) ) as $post) {
setup_postdata( $post );
echo "<div class='col-lg-4 col-md-4 col-sm-4 col-xs-12 post-link'>";
echo '<h4 class="title"><a href="'.get_permalink($post->ID).'">'.get_the_title().'</a></h4>';
echo '<div class="post-thumb">';
echo '<a href="'.get_permalink($post->ID).'">';
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
echo '</a>';
echo '</div>';
echo "</div>";
}
if( $total_posts > 3 )
{   ?>
<a href="#">View all</a>
<?php   }
echo "</div>";  /* sub-category-wrapper */
}
?>
</div>

<?php get_footer(); ?>
<a href="view-all">View all</a>

如果它们位于一个目录

中,只需更改上面代码中的这一行