1
I would like to take the URL of thumbnails in the Wordpress database using pure PHP to put in a Magento project in order to show the posts on the home page.
Like that relationship Magento -> Wordpress it’s a little complicated, I’d like someone to help me catch the Featured Image
of each post to insert on the Ecommerce homepage.
What I’ve already 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:
I recommend that in addition to image, post the real data, it is not always easy to test data that are in photos. I kicked an answer, there may be flaws, but the way is this.
– Guilherme Nascimento
It has either XMLRPC or the semi-official JSON API plugin, but it’s not pure PHP.. If the title was to "take Thumb externally (out of wp)", it could answer, otherwise it would be an answer outside the scope of what was asked.
– brasofilo