LoginSignup
0
0

More than 5 years have passed since last update.

pre_get_posts

Posted at

クエリーをカスタマイズするときの「pre_get_posts」の書き方

functions.php
function pre_get_posts_func($query)
{
    if ($query->is_post_type_archive && $query->query_vars['post_type'] == 'xxx') {
        $query->set('meta_query', array(
            //...
        ));
    }
}
add_action('pre_get_posts', 'pre_get_posts_func');
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