Skip to main content
deleted 189 characters in body
Source Link
Milo
  • 78.8k
  • 4
  • 127
  • 168

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid.

The guid is present on my report and not present on my preview (this is intended as I want to catch the failiurefailure).

However, when I run the script for preview, the get_posts returns one post which seems to be the latest post published.

` $args = array(
            "post_type" => array($type),
            "posts_per_page" => 1,
            "post_status" => "publish",
            "orderby" => "date",
            "order" => "DESC",
            "meta_query" => array(
                "key" => "_fixtures",
                "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324
                "compare" => "="
            )
        );  
        $posts = get_posts($args);
        return $posts;`$posts;

The report (which has the meta data 12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of 12AB3136.

I suppose my question is:

Why does get_posts meta query return
a) the latest post and
b) a post with a guid that doesn't = the given key parameter
.

Thanks.

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid.

The guid is present on my report and not present on my preview (this is intended as I want to catch the failiure).

However, when I run the script for preview, the get_posts returns one post which seems to be the latest post published.

` $args = array(
            "post_type" => array($type),
            "posts_per_page" => 1,
            "post_status" => "publish",
            "orderby" => "date",
            "order" => "DESC",
            "meta_query" => array(
                "key" => "_fixtures",
                "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324
                "compare" => "="
            )
        );  
        $posts = get_posts($args);
        return $posts;`

The report (which has the meta data 12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of 12AB3136.

I suppose my question is:

Why does get_posts meta query return
a) the latest post and
b) a post with a guid that doesn't = the given key parameter
.

Thanks.

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid.

The guid is present on my report and not present on my preview (this is intended as I want to catch the failure).

However, when I run the script for preview, the get_posts returns one post which seems to be the latest post published.

$args = array(
    "post_type" => array($type),
    "posts_per_page" => 1,
    "post_status" => "publish",
    "orderby" => "date",
    "order" => "DESC",
    "meta_query" => array(
        "key" => "_fixtures",
        "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324
        "compare" => "="
    )
);  
$posts = get_posts($args);
return $posts;

The report (which has the meta data 12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of 12AB3136.

I suppose my question is:

Why does get_posts meta query return
a) the latest post and
b) a post with a guid that doesn't = the given key parameter
.

Thanks.

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid.

The guid is present on my report and not present on my preview (this is intended as I want to catch the failiure).

However, when I run the script for preview, the get_posts returns one post which seems to be the latest post published.

$args = array( "post_type" => array($type), "posts_per_page" => 1, "post_status" => "publish", "orderby" => "date", "order" => "DESC", "meta_query" => array( "key" => "_fixtures", "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324 "compare" => "=" ) ); $posts = get_posts($args); return $posts;

` $args = array(
            "post_type" => array($type),
            "posts_per_page" => 1,
            "post_status" => "publish",
            "orderby" => "date",
            "order" => "DESC",
            "meta_query" => array(
                "key" => "_fixtures",
                "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324
                "compare" => "="
            )
        );  
        $posts = get_posts($args);
        return $posts;`

The report (which has the meta data 12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of 12AB3136.

I suppose my question is, :

Why does get_posts meta query return a
a) the latest post and b
b) a post with a guid that doesn't = the given key parameter
.

Thanks.

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid.

The guid is present on my report and not present on my preview (this is intended as I want to catch the failiure).

However, when I run the script for preview, the get_posts returns one post which seems to be the latest post published.

$args = array( "post_type" => array($type), "posts_per_page" => 1, "post_status" => "publish", "orderby" => "date", "order" => "DESC", "meta_query" => array( "key" => "_fixtures", "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324 "compare" => "=" ) ); $posts = get_posts($args); return $posts;

The report (which has the meta data 12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of 12AB3136.

I suppose my question is, Why does get_posts meta query return a) the latest post and b) a post with a guid that doesn't = the given key parameter.

Thanks.

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid.

The guid is present on my report and not present on my preview (this is intended as I want to catch the failiure).

However, when I run the script for preview, the get_posts returns one post which seems to be the latest post published.

` $args = array(
            "post_type" => array($type),
            "posts_per_page" => 1,
            "post_status" => "publish",
            "orderby" => "date",
            "order" => "DESC",
            "meta_query" => array(
                "key" => "_fixtures",
                "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324
                "compare" => "="
            )
        );  
        $posts = get_posts($args);
        return $posts;`

The report (which has the meta data 12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of 12AB3136.

I suppose my question is:

Why does get_posts meta query return
a) the latest post and
b) a post with a guid that doesn't = the given key parameter
.

Thanks.

Source Link

get posts meta query returning the latest post if no meta key found

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid.

The guid is present on my report and not present on my preview (this is intended as I want to catch the failiure).

However, when I run the script for preview, the get_posts returns one post which seems to be the latest post published.

$args = array( "post_type" => array($type), "posts_per_page" => 1, "post_status" => "publish", "orderby" => "date", "order" => "DESC", "meta_query" => array( "key" => "_fixtures", "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324 "compare" => "=" ) ); $posts = get_posts($args); return $posts;

The report (which has the meta data 12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of 12AB3136.

I suppose my question is, Why does get_posts meta query return a) the latest post and b) a post with a guid that doesn't = the given key parameter.

Thanks.