模板里的index.php文件没有<?php if (have_posts()) : ?>这行代码,该如何解决?新手求助!

2025-04-07 07:46:02
推荐回答(2个)
回答1:


/**
* Template for startpage
*
* @package WordPress
* @subpackage ut-strange
* @since Strange 1.0
*/

get_header();

?>


$slider_items = get_option(UT_THEME_INITIAL.'slider_items_item');
if( is_array( $slider_items ) && !empty( $slider_items ) ):
?>



    $item ): ?>































$welcome_message = get_option(UT_THEME_INITIAL.'home_welcome_text');
if( !empty( $welcome_message ) ):
?>










$tax_query = ap_get_wp_query_taxonomy_arg_array( get_option( UT_THEME_INITIAL.'home_featured2_category' ) );

$teaser_items = get_option(UT_THEME_INITIAL.'home_featured1_item');
if( is_array( $tax_query ) || is_array( $teaser_items ) ) :
?>





if( is_array( $teaser_items ) ):
foreach( $teaser_items as $num => $item ):
?>












endif; ?>



$_taxquery = $tax_query;
unset($_taxquery['relation']);
if( is_array( $tax_query ) && !empty($_taxquery) ) : ?>

$args = array( 'posts_per_page' => 3, 'tax_query' => $tax_query );
query_posts($args);
while ( have_posts() ): the_post();
$attr_hidden = array();
$lock_class = '';
$pass=false;
if ( ( !empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) ){
$attr_hidden = array('style'=>'visibility:hidden;');
$lock_class = ' class="lock"';
$pass=true;
}
?>

id="post-">


if( has_post_thumbnail() ): echo ($pass?'
':''); the_post_thumbnail(UT_THEME_INITIAL.'teaser', $attr_hidden); echo ($pass?'
':'');
else: ?>
<?php the_title(); ?>













回答2:

没看见有 这行代码啊!!!