I want to check the existence of an article from two pieces of information ($post_info1, $post_info2). Is WP_Query faster than the following get_posts?
// Check existence $exist = get_posts (array ( 'post_type' =>'post', 'meta_query' =>array ( 'relation' =>'AND', array ( 'key' =>'key1', 'value' =>$post_info1, 'type' =>'CHAR', 'compare' =>'=' ), array ( 'key' =>'key2', 'value' =>$post_info2, 'type' =>'CHAR', 'compare' =>'=' ) ), ));
I only know that the information to be acquired is different, and that get_posts is via WP_Query, but I'm not sure how to use it, so I'd like to tell you about that.
Thanks for your understanding.
Answer # 1
Is WP_Query faster than get_posts below?
I don't think it will change.
Acquired information is different
Depends on the specification method (contents). I think that it does not change greatly with the degree that some default values are different.
【get_posts () | Function | WordPress Developer Resources】
I think it depends on people. I often use WP_Query, but the reporter of the following article seems to use get_posts.
[So far! Exploring the characteristics of [WP_Query] and [get_posts ()] in WordPress | Web production company LIG in Tokyo Ueno]
- php - i want to add the block added by acf to allowed_block_types
- php - call to undefined function have_posts () is displayed [wordpress]
- php - validate post with wordpress
- php - i can't fly outside the wordpress page link
- php - how to load your own js file on the wordpress post page
- php - i can't click the number of pages in the page view
- php - [wordpress] i want to display the "new mark" in the navigation when there is a new article
- php - wordpress shows an error that css is not reflected
- php - i want to display an error or redirect