admin管理员组文章数量:1130349
So basically I'm trying to add multiple custom post type in my taxonomy archive. Here's my code:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
<?php
$args_wisata = array (
'post_type' => 'wisata' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$wisatas = new WP_Query( $args_wisata );
if ( $wisatas->have_posts() ) :
?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $wisatas->have_posts() ) : $wisatas->the_post();
get_template_part( 'template-parts/content', 'wisata' );
endwhile;
?>
</div>
The code above meant to output TWO different custom post type TRIP & WISATA within taxonomy archive.
BUT it always causing white screen, but when it only looping ONE custom post type, it works fine. Here's the code for only one custom post type:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
I don't know what might be causing this? Really frustrate me... Please someone help me! Lol.
NOTE: my wp-config.php already has define('WP_DEBUG', true); but there is no error shown, only blank white page.
So basically I'm trying to add multiple custom post type in my taxonomy archive. Here's my code:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
<?php
$args_wisata = array (
'post_type' => 'wisata' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$wisatas = new WP_Query( $args_wisata );
if ( $wisatas->have_posts() ) :
?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $wisatas->have_posts() ) : $wisatas->the_post();
get_template_part( 'template-parts/content', 'wisata' );
endwhile;
?>
</div>
The code above meant to output TWO different custom post type TRIP & WISATA within taxonomy archive.
BUT it always causing white screen, but when it only looping ONE custom post type, it works fine. Here's the code for only one custom post type:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
I don't know what might be causing this? Really frustrate me... Please someone help me! Lol.
NOTE: my wp-config.php already has define('WP_DEBUG', true); but there is no error shown, only blank white page.
1 Answer
Reset to default 0Will answer it myself to close this question / thread.
From @Sally CJ
You forgot to close the if - add
<?php endif; ?>after those two</div>(the closing tag for the archive-grid DIV)
So basically I'm trying to add multiple custom post type in my taxonomy archive. Here's my code:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
<?php
$args_wisata = array (
'post_type' => 'wisata' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$wisatas = new WP_Query( $args_wisata );
if ( $wisatas->have_posts() ) :
?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $wisatas->have_posts() ) : $wisatas->the_post();
get_template_part( 'template-parts/content', 'wisata' );
endwhile;
?>
</div>
The code above meant to output TWO different custom post type TRIP & WISATA within taxonomy archive.
BUT it always causing white screen, but when it only looping ONE custom post type, it works fine. Here's the code for only one custom post type:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
I don't know what might be causing this? Really frustrate me... Please someone help me! Lol.
NOTE: my wp-config.php already has define('WP_DEBUG', true); but there is no error shown, only blank white page.
So basically I'm trying to add multiple custom post type in my taxonomy archive. Here's my code:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
<?php
$args_wisata = array (
'post_type' => 'wisata' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$wisatas = new WP_Query( $args_wisata );
if ( $wisatas->have_posts() ) :
?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $wisatas->have_posts() ) : $wisatas->the_post();
get_template_part( 'template-parts/content', 'wisata' );
endwhile;
?>
</div>
The code above meant to output TWO different custom post type TRIP & WISATA within taxonomy archive.
BUT it always causing white screen, but when it only looping ONE custom post type, it works fine. Here's the code for only one custom post type:
<?php
$args_trip = array (
'post_type' => 'trip' ,
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'destination',
'field' => 'slug',
'terms' => $term
)
)
);
$trips = new WP_Query( $args_trip );
?>
<?php
if ( $trips->have_posts() ) : ?>
<div class="archive-grid">
<?php
/* Start the Loop */
while ( $trips->have_posts() ) : $trips->the_post();
get_template_part( 'template-parts/content', 'trip' );
endwhile;
wp_reset_postdata();
?>
</div>
<hr>
I don't know what might be causing this? Really frustrate me... Please someone help me! Lol.
NOTE: my wp-config.php already has define('WP_DEBUG', true); but there is no error shown, only blank white page.
-
You forgot to close the
if- add<?php endif; ?>after those two</div>(the closing tag for thearchive-gridDIV). – Sally CJ Commented Nov 9, 2018 at 3:36 - WOW thank you so much! I've been blind the whole time!! I'm still very new about PHP and the solution actually so simple lol. Thank you!! @SallyCJ – Syamsul Alam Commented Nov 9, 2018 at 7:50
-
No problem Syamsul. Even I sometimes make such a (silly) mistake.. :) And if I may give you a tip: If you ever see that "white screen" again (on other pages) - and you couldn't find anything wrong in your code, then try looking for any PHP errors in the page source (HTML), and/or (enable debugging and) check the
error_logfile. =) – Sally CJ Commented Nov 9, 2018 at 8:50
1 Answer
Reset to default 0Will answer it myself to close this question / thread.
From @Sally CJ
You forgot to close the if - add
<?php endif; ?>after those two</div>(the closing tag for the archive-grid DIV)
本文标签: Multiple Custom Post Type in Taxonomy Archive Causing White Screen
版权声明:本文标题:Multiple Custom Post Type in Taxonomy Archive Causing White Screen 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749194065a2330551.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


if- add<?php endif; ?>after those two</div>(the closing tag for thearchive-gridDIV). – Sally CJ Commented Nov 9, 2018 at 3:36error_logfile. =) – Sally CJ Commented Nov 9, 2018 at 8:50