Skip to content
Advertisement

WordPress Find ID of a Post with a specific meta value

I have about 25,000 posts here (and rising). All of them under a Custom Post Type “lead”. Each post has meta information, including a variable called “uniqid”. this uniqid is a url parameter. now i need the post id where exactly this uniqid exists.

Now my question is if there is a way to speed up this determination.

I have tried 2 ways once a wp_query and get_results.

I ask because this function that determines the post id is always noted by plugin “query monitor” that it is slow.

These are the 2 approaches, both work. I just wonder if it is possible to speed up here?

The WP_Query solution.

The select get_results solution.

Advertisement

Answer

Please use this meta_query condition on the same query, it helps you.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement