0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

wordpress WP_QueryでDBの「wp_postmeta」内の値でクエリする

Last updated at Posted at 2024-12-13

WordPressの多言語化プラグインを利用した際に、
ロケールが日本語のもの、英語のものと一覧に出す際に
wp_postmetaテーブルにあるmeta_keyが「_locale」のもので
クエリを出し分けたかったので調査し備忘録として残します。

		$args = array(
			'post_type'  => 'products',//ポストタイプ
			'posts_per_page'=> 72,//取得数
			'paged'         => $paged,//ページャー
			'post_status' => 'publish',//公開状態
			'meta_key' => '_locale',//meta_keyが「_locale」
			 'meta_query' => array(
			    'relation' => 'AND',
			    array(
			      'key' => '_locale', //meta_keyが「_locale」
			      'value' => 'en_US',//meta_valueが「en_US」
			      'compare' => '=', 
			    ))
		);
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?