>  기사  >  CMS 튜토리얼  >  WordPress에서 특정 기사 목록을 호출하는 방법

WordPress에서 특정 기사 목록을 호출하는 방법

藏色散人
藏色散人원래의
2019-12-28 09:48:233447검색

WordPress에서 특정 기사 목록을 호출하는 방법

워드프레스에서 특정 기사 목록을 호출하는 방법은 무엇입니까?

워드프레스 테마 제작 및 개발 시, 특정 페이지의 특정 글이나 글 목록을 불러야 하는 경우가 종종 있습니다. 다음으로는 워드프레스 글 목록을 불러오는 방법을 알려드리겠습니다.

추천: "Wordpress Tutorial"

웹사이트의 최신 기사 호출:

코드는 다음과 같습니다:

<?php
query_posts(&#39;showposts=10&orderby=new&#39;); 
//showposts=10表示10篇
while(have_posts()): the_post();
?>
<li><a href="<?php the_permalink(); ?>"target="_blank"><?php the_title() ?></a></li> 
//这里可以写成你自己需要的样式
<?php endwhile; ?>

임의의 기사 호출:

코드는 다음과 같습니다:

<?php
query_posts(&#39;showposts=10&orderby=rand&#39;); 
//showposts=10表示10篇
while(have_posts()): the_post();
?>
<li>
<a href="<?php the_permalink(); ?>"target="_blank"><?php the_title() ?></a>
</li> 
//这里可以写成你自己需要的样式
<?php 
endwhile; 
?>

Call 특정 카테고리의 최신 기사:

코드는 다음과 같습니다.

<?php
query_posts(&#39;showposts=10&cat=1&#39;); 
//cat=1为调用ID为1的分类下文章
while(have_posts()) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>"title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php 
endwhile; 
?>

특정 카테고리의 기사 제외:

코드는 다음과 같습니다.

<?php
query_posts(&#39;showposts=10&cat=-1&#39;); 
//cat=-1为排除ID为1的分类下文章
while(have_posts()) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>"title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php 
endwhile; 
?>

위는 기사 목록의 호출 방법입니다. 필요한 효과를 얻으려면 예제의 코드를 결합하십시오.

위 내용은 WordPress에서 특정 기사 목록을 호출하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.