Reputation: 558
I am using the get_previous_post()
to check if the first custom post type so I can add a condition. It works if it's not equal to 0 (the first post), to make it work I need to parse the output.
The following didn't work, I get the error Argument ($str) must be of type string
$checkFirst = get_previous_post();
<?php !(wp_parse_str(strlen($checkFirst)) == 0) ? 'something' : '';?>
I have also tried :
wp_parse_str(strlen($checkFirst), $output)
<?php !($output[strlen($checkFirst)] == 0) ? 'something' : '';?>
Upvotes: 2
Views: 283
Reputation: 9097
Why do you think you need to parse it?
According to the get_previous_post
Docs, it returns:
So you could check its value like this:
$checkFirst = get_previous_post();
echo $checkFirst
? 'There is a previous post'
: 'No, this is the first post';
You don't need to use strlen
or wp_parse_str
.
Upvotes: 3