我試圖從我的WordPress站點之一拉到使用WP REST API的另一個帖子,我已經成功地完成了這一點,並且帖子在其他網站,但現在的問題是,我想每個崗位是點擊,使其敞開全文(崗位)的被點擊....從一個WordPress站點拉到一個鏈接到每個職位的帖子
$json = file_get_contents('http://mywebsite.com/blog/wp-json/posts?filter[posts_per_page]=4');
// Convert the JSON to an array of posts
$posts = json_decode($json);
foreach ($posts as $p){
echo '<div style="color: #fff; float: left;" class="col-md-3 col-sm-3 col-lg-3">';
// Output the featured image (if there is one)
echo $p->featured_image ? '<img src="' . $p->featured_image->guid . '">' : '';
echo '<h5>Title: ' . $p->title . '</h5>';
// echo '<p>Date: ' . date('F jS', strtotime($p->date)) . '</p>';
$summary = $p->excerpt;
$pos=strpos($summary, ' ', 100);
$summary = substr($summary, 0, 100);
echo '<p>';
echo $summary;
echo '</p>';
echo '</div>';
}
所以,當我現在需要是拉鍊接到每個職位旁邊....
我只是想這樣的事情:echo '<p>Link: ' . $p->link. '</p>';
歡迎堆棧溢出,這是一個正確的,因爲你試圖回答,但一個貧窮的答案,使之更好的請提供您在這種情況下,使用鏈接的資源wordpress文檔並解釋你的代碼在做什麼。 –
嘿感謝您的建議 這裏是資源:https://developer.wordpress.org/reference/functions/get_permalink/ –