Why the function get_posts returns the wrong post?
-
Hi,
I noticed a strange behaviour of the function get_posts. I’ve defined a custom post type called “evento” that seems to work correctly. However using this array as parameter:
$args array(3) post_name: "turbulence-on-the-banks" post_type: "evento" numberposts: 1When I execute the following code to check if a post exists by slug it returns the wrong item:
$args = array( 'post_name' => $slug, 'post_type' => $content_type, 'numberposts' => 1, ); $posts = get_posts( $args ); $posts[0]['post_type'] "evento" $posts[0]['post_name'] "giornata-della-solidarieta-2024"How is it possible?
In this case the post doesn’t exist and I expect an empty array.
I’m using WordPress 6.5.3.
Thank you very much.
Claudio
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Why the function get_posts returns the wrong post?’ is closed to new replies.