I would like to get the URL of the thumbnails in the WordPress database using pure PHP to put in a Magento project in order to show the posts on the homepage.
How this relationship Magento - > Wordpress is a bit complicated, I would like someone to help me get the Featured Image
of each post to enter on the ecommerce home page.
What I've done:
function SimpleLoopWordpress (){
try {
// PDO em ação!
$pdo = new PDO ( "mysql:host=localhost;dbname=", "", "", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") );
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date ASC";
$stmt = $pdo->prepare($sql);
$stmt->execute();
$i = 1;
echo '<div class="row">';
while ( $linha = $stmt->fetch ( PDO::FETCH_OBJ ) ) {
?>
<div class="col-md-6">
<?php
echo $i++;
echo FEATURED IMAGE <--------
echo $linha->post_title;
echo $linha->post_date;
echo $linha->post_content;
?>
</div>
<?php
}
echo '</div>';
}
I'll probably get this image here: