8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WordPress、複数カテゴリを指定

Posted at

WordPress、複数カテゴリを指定

■about

WordPress、複数カテゴリを指定
get_posts() 関数のカテゴリ引数の「category__and」に、カテゴリIDを配列で指定する。

■code

php
$get_posts_args = array(
//23,25を選ぶ
    'category__and' => array( 23,25 ),
//ID60を選ばない
	'cat' => -60,
    'numberposts' => 2,
    'order' => 'DESC',
);

■reference

ID指定した複数カテゴリ全てに属する投稿記事を新着順リスト表示
http://alphasis.info/2011/07/wordpress-function-get_posts-category__and/

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?