Wordpress searchandfilter插件和php代码结果问题
我是这个论坛的新手。在wordpress模板文件中查找我的问题的解决方案。也许有人能帮你解决这个问题。这是我的模板文件代码Wordpress searchandfilter插件和php代码结果问题,php,wordpress,Php,Wordpress,我是这个论坛的新手。在wordpress模板文件中查找我的问题的解决方案。也许有人能帮你解决这个问题。这是我的模板文件代码 <?php /* Template name: recipies */ get_header();?> <header class="entry-header "> <h1 class="entry-title">Recipies</h1> </header&g
<?php
/*
Template name: recipies
*/
get_header();?>
<header class="entry-header ">
<h1 class="entry-title">Recipies</h1>
</header>
<?php
$pack_expire = 0;
$sub_pack = WPUF_Subscription::get_user_pack( get_current_user_id() );
$allowed_packs = get_post_meta( $post->ID, '_wpuf_res_subscription', true );
if ( !$sub_pack ) {
$pack_expire=1;
}
$pack_id = is_array( $sub_pack ) ? intval( $sub_pack['pack_id'] ) : 0;
if ( !$pack_id ) {
$pack_expire=1;
}
// check expiration
$expire = isset( $sub_pack['expire'] ) ? $sub_pack['expire'] : 0;
if ( strtolower( $expire ) == 'unlimited' || empty( $expire ) ) {
$has_expired = false;
}
else if ( ( strtotime( date( 'Y-m-d', strtotime( $expire ) ) ) >= strtotime( date( 'Y-m-d', time() ) ) ) ) {
$has_expired = false;
} else {
$has_expired = true;
}
if ( $has_expired ) {
$pack_expire=1;
}
$pack_id = is_array( $sub_pack ) ? intval( $sub_pack['pack_id'] ) : 0;
if ( ! in_array( $pack_id, $allowed_packs ) ) {
$pack_expire=1;
}
if($pack_expire==0){?>
<div class="container recipes-boxes">
<div class="row media-justify-content mt-0">
<div class="col-sm-12 mb-4">
<?php echo do_shortcode('[searchandfilter id="1003"]');?> <!-- Searchandfilter plugin -->
</div>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="col-sm-4 img-container">
<h2 class="text-center"><a class="r-shadow" href="<?php the_permalink(); ?>"><?php the_title() ;?></a></h2>
<?php the_post_thumbnail(); ?>
<h6 class="recipe-list-comment"><a class="shadow" href="<?php the_permalink(); ?>">Comment</a></h6>
</div>
<?php endwhile; ?>
<?php echo the_posts_pagination( array( 'mid_size' => 1 ) );?>
<?php else : ?>
<p><?php _e( 'No recipes found' ); ?></p>
<?php endif; ?>
<div class="container my-5">
<?php }else{
echo '<a href="/payment/?section=subscription" class="nav-link">Pay now</a>';
} ?>
</div>
<?php get_footer();?>
报酬
这些div没有关闭:
我建议您添加一个var\u转储($pack\u expire);如果($pack\u expire==0),请在前一行执行die
line检查值是否正确谢谢您的回复。说得好,分区现在关闭了。但问题依然存在。我尝试添加var\u dump($pack\u expire);死亡如果($pack\u expire==0)我得到两个结果。如果搜索返回某个内容,则显示int(1)
如果搜索未找到任何内容,则显示int(0)