Php 自定义post类型分页无法正常工作
我创建了这个页面并编写了一些分页代码,它工作正常。但问题是分页页面似乎没有模板。它没有显示导航栏(我放在header.php上),我也不知道如何更改这些页面模板 我试图创建一个archive-card-custom.php页面,但没有成功Php 自定义post类型分页无法正常工作,php,wordpress,pagination,Php,Wordpress,Pagination,我创建了这个页面并编写了一些分页代码,它工作正常。但问题是分页页面似乎没有模板。它没有显示导航栏(我放在header.php上),我也不知道如何更改这些页面模板 我试图创建一个archive-card-custom.php页面,但没有成功 <?php get_header();?> <?php $home_url = get_template_directory_uri(); ?> <div class="container-xxl small-info
<?php get_header();?>
<?php $home_url = get_template_directory_uri(); ?>
<div class="container-xxl small-infos ">
<div class="infos ">
<h1>card-custom</h1>
</div>
</div>
</div>
</div>
</header>
<main class="page-card-custom" tabindex="-1" role="main">
<section class="card-custom-sec">
<div class="container-xxl">
<h2> Lorem Ipsum
</h2>
<div class="wrapper">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type'=>'card-custom', //
'posts_per_page' => 2,
'paged' => $paged,
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="card-custom">
<div class="header">
<img src="<?php the_post_thumbnail_url()?>" alt="">
</div>
<div class="body">
<span class="title"><?php the_title(); ?></span>
<p class="info">
<?php the_content(); ?>
</p>
</div>
</div>
<?php endwhile;
?>
</div>
<a class="btn" href="../contact/ " target="_blank"> <span>Lorem Ipsum</span></a>
</div>
</section>
</main>
<div class="container-xxl d-flex justify-content-center align-items-center px-4 py-4 pagination">
<?php
$total_pages = $loop->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« Prev'),
'next_text' => __('NExt »'),
));
}
}
?>
</div>
<script>
const header = document.querySelector("header");
header.classList.add("small-header");
header.classList.add("card-custom");
</script>
<?php
get_footer();
卡片定制
乱数假文
“alt=”“>
const header=document.querySelector(“header”);
header.classList.add(“小标题”);
header.classList.add(“卡片自定义”);