When pulling numeric data ( a number ) which has been saved to post_meta when editing a page - for example:
$number = get_post_meta( $post->ID, 'number', true );
And then using that value with get_posts in a meta_query - for example:
$args = array (
'posts_per_page' => 4, // limit ##
'post_type' => 'post',
'post__not_in' => array ( $post->ID ), // exclude self ##
'meta_query' => array (
array (
'key' => 'related_page',
'value' => $number,
)
),
);
$posts = get_posts( $args );
Do we first need to type juggle the retrieved value to be an integer, as it appears to be returned as a string:
var_dump($args)
gives:
array(5) {
["posts_per_page"]=>
int(4)
["post_type"]=>
string(4) "post"
["post__not_in"]=>
array(1) {
[0]=>
int(1387)
}
["meta_query"]=>
array(3) {
[0]=>
array(2) {
["key"]=>
string(15) "related_page"
["value"]=>
string(1) "10"
}
}
}
Should I be controlling the values using other custom field settings such as "compare" or "type" ?
{}
button above the editor's content box.