I've been trying to combine two database queries in to one. Now I've finally done this (yeah). But One problem keeps me from completing this task. And I bet its really simple but I can't seem to get it to work.
I've a database query set-up and it works.
$sql = "SELECT `guid` FROM `pf_posts` WHERE `id` IN (SELECT `meta_value`
FROM `pf_postmeta`
WHERE `meta_key` LIKE '_thumbnail_id'
AND `post_id` = $post_id)";
$result = mysqli_query($wp_database, $sql);
$images = mysqli_fetch_all($result, MYSQLI_ASSOC);
mysqli_free_result($result);
foreach ($images as $image): ?>
<div>
<?php print_r($image); ?>
</div>
<?php endforeach; ?>
This get's me the correct value BUT in a print_r which get's me this:
Array ( [guid] => http://mydomein.nl/wp-content/images-001.jpg )
But I would like to remove the Array ( [guid] => and the last ) part from the print_r.
I've looked into string replace but I have no idea how to set correct. I would like to be able to echo it. I've gotten the code for the database from here:
How can I retrieve posts with featured images from a WordPress database if WordPress is no longer installed? [closed]