0
我寫下面的代碼如下,以顯示我的首頁在WordPress的前3個博客文章。奇怪的代碼添加到自定義功能在wordpress
function wptuts_recentpost($atts, $content=null){
$getpost = get_posts(array('number' => 1));
$getpost = $getpost[0];
$return = "<img src=" . get_the_post_thumbnail($getpost->ID) . " >" . "<br />" . $getpost->post_title . "<br />" . $getpost->post_excerpt . "…";
$return .= "<br /><br /><a href='" . get_permalink($getpost->ID) . " style='color: rgb(255, 255, 255); background-color: rgb(117, 172, 255); font-size: 18px; margin: 10px; width: 162px;' class='edgtf-btn edgtf-btn-large edgtf-btn-solid edgtf-btn-custom-hover-bg edgtf-direction-aware-hover'><span class='edgtf-btn-text-holder'><span class='edgtf-btn-text'>read more →</span><div class='edgtf-btn-background-holder'>
<span class='edgtf-btn-background' style='background-color: rgb(0, 0, 0); top: 30px; left: 65px;'></span>
</div></a>";
return $return;
}
add_shortcode('newestpost', 'wptuts_recentpost');
此代碼用於正常工作,但是當我最近檢查了一遍,永久鏈接這個代碼提供了錯誤的鏈接(部分正確的,但它在最後添加「%20style =」)。
我該如何解決這個問題,以便它能給我提供正確的鏈接。
「風格**刪除風格前的空間** –