Heim  >  Artikel  >  php教程  >  让PHP里包含PHP

让PHP里包含PHP

WBOY
WBOYOriginal
2016-06-06 20:08:391299Durchsuche

有这样一段代码,我能够在分类ID为9的时候,输出 Hello World ?php if ( is_category ( 9 )) { echo ' Hello World ' ; } ? 接下来,我希望在分类为9的时候,输出一段文章列表: ?php if ( is_category ( 9 )) { ? ?php $posts = get_posts ( ' showposts=15

有这样一段代码,我能够在分类ID为9的时候,输出 Hello World


if(is_category(9)){
    
echo'Hello World';
}
?>

接下来,我希望在分类为9的时候,输出一段文章列表:


if(is_category(9)){
?>
    
$posts = get_posts('showposts=15&cat=9'); ?>
    
if($posts) : ?>
    

    foreach($postsas$post) : setup_postdata($post); ?>
        
  • the_title(); ?>
        
    endforeach; ?>
        
        
    endif; ?>

    }
    ?>

    用好 { 以及 就行,笔记如上,以此备忘。

    Stellungnahme:
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn