我基本上想显示一些php,如果它是在类别工作内部,我知道如何做if else语句和输出PHP自己,但不是很确定如何结合二,如果有人能启发我,将不胜感激。基本代码如下,我猜我不允许有一个<?php inside a <?php?
PHP里面的PHP if else语句 - wordpress
非常感谢!
<?php // Outputting related work if in work category
if (in_category('work')) {
echo "
<section class='work'>
<h2>Also of interest</h2>
<?php query_posts('category_name=work&posts_per_page=3&order=DSC&offset=1&orderby=ID');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<a href='<?php the_permalink() ?>'>
<?php the_post_thumbnail();?>
<h3><?php the_title(); ?></h3>
<span>Redesign</span>
<?php the_excerpt($strip_teaser); ?>
</a>
</article>
<?php endwhile; endif; wp_reset_query();?>
<a class='all' href='/work'>→ View all work</a>
</section> <!-- end work -->
";
}
?>
谢谢,这使事情变得更容易! – Nick