我正在尝试使用 *is_page()* 来显示以在单个模板文件中显示 2 个不同的内容。我的代码看起来像
<?php
if ( is_page('news') ) {
// Insert HTML/PHP for News - code shown below
}
else ( is_page('review') ){
// Insert HTML/PHP for Review - code shown below
}
?>
这对我不起作用......不知道为什么?我已经显示了我尝试在下面插入的新闻/评论代码
新闻的 HTML/PHP
<div class="news">
<?php query_posts('cat=-89');?>
<?php while ( have_posts() ) : the_post(); ?>
<article class="summary">
<div class="content_wrap cont_page ">
<header>
<h2> <a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?> </a></h2>
<p> <span class="author">
<?php the_author() ?>
</span><br />
<span class="date">
<?php the_date(); ?>
</span>
</header>
<div class="entry-content">
<?php the_excerpt(); ?>
<?php include('share.php')?>
</div>
<aside class="right">
<?php the_post_thumbnail(); ?>
</aside>
</div>
</article>
<?php
<?php endwhile; ?>
</div>
用于审查的 HTML/PHP
<div class="review">
<?php query_posts('cat=89,246,247,248');?>
<?php while ( have_posts() ) : the_post(); ?>
<article class="summary
<?php
// Custom posts stylings
if ( has_post_format( 'video' )) {
echo 'video';
} elseif ( in_category('orange') ) {
echo 'orange';
} else {
echo 'white';}
?>
">
<div class="content_wrap cont_page ">
<div class="entry-content">
<?php if ( has_post_format( 'video' )) {
// Get the video URL and put it in the $video variable
$videoID = get_post_meta($post->ID, 'video_url', true);
// Echo the embed code via oEmbed
echo '<iframe src="http://player.vimeo.com/video/'.$videoID.'?title=0&byline=0&portrait=0&color=ffffff" width="405" height="285" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
// echo '<iframe src="http://player.vimeo.com/video/'.$videoID.'" width="405" height="285" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
}
else the_post_thumbnail();
?>
</div>
<aside class="right">
<header>
<h2> <a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?> </a></h2>
</header>
<div class="entry-content">
<?php the_excerpt(); ?>
</div>
<?php include('share.php')?>
</aside>
</div>
</article>
<?php
// DISABLED/S default format
// get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
</div>