Một số function thường dùng khi làm theme wordpress (some functions popular for work do theme worpdress)
1.Cắt từ post content (custom excerpt from post content).
1 2 3 4 5 6 7 8 9 10 11 12 |
function custom_excerpt($string="",$limitword="",$kytu=""){ $string=strip_tags($string); $string= preg_replace('/\n/',' ', trim($string)); $array = explode(' ', $string); $string=""; $run_for = (count($array) > $limitword) ? $limitword : count($array); for($i=0; $i<$run_for;$i++): $string .=$array[$i]." "; endfor; $string = strip_shortcodes($string); return $string.$kytu; } |
Bình luận
Mọi sự sao chép xin ghi rõ nguồn là fcwordpress.net
Chuyên trang về wordpress: hướng dẫn thiết kế theme, plugin, thủ thuật wordpress