好問題!答案很簡單:編寫你自己的功能!
打開您喜歡的編輯器了functions.php
搗碎鍵盤上的隨機按鈕,直到你得到的東西是這樣的:
function my_awesome_excerpt ($post_id = false, $full = false, $length = 22) {
if (!$post_id) global $post;
else $post = get_post($post_id);
$text = $post->post_content;
if ($full) return $text;
else {
$text_array = explode(' ', $text);
$return_string = array();
for ($i = 0; $i <= $length; $i++)
array_push($return_string, $text_array[$i]);
$new_awesome_string = '<p>';
$new_awesome_string .= implode(' ', $return_string);
$new_awesome_string .= '</p><p class="readmore">';
$new_awesome_string .= '<a href="' . get_permalink($post_id) . '">';
$new_awesome_string .= 'Read More' . '</a></p>';
return $new_awesome_string;
}
}
現在,你已經準備好最酷的部分。一旦你在你的循環,你可以寫出這樣的一些魔術:
echo my_awesome_excerpt();
它會自動地吐出摘錄。它使用全球后變量和一切!你甚至可以用它的循環之外:
echo my_awesome_excerpt($cpt->ID, 22);
並設置自己的特殊長度!
或者你也許只是在你的心中知道這不值得,你只是想展示整件事情。那個樣子怎麼樣?
在循環中,你將不得不給它一個職位ID,對此感到抱歉。
echo my_awesome_script($post->ID, false);
我希望這有助於。祝你有美好的一天!
嗯不錯 但我已經通過檢查get_option()函數來完成。 :) – Bilal