Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
wordpress の投稿を 3 つの部分に分けて表示したいと思います。
題名
投稿本文の最初の 50 語。
最初の 50 語を削除したメインの投稿テキスト (既に表示されているため)
私がよくわからないのは、最初の 50 語だけを表示し、次に表示したいメインの投稿テキストから最初の 50 語を除外する方法です。
何か案は?
ありがとう。
最初の 50文字ではなく、最初の50単語を探している場合:
$title = $post->post_title; $words = explode(' ', $post->post_content); if(count($words) > 50) { $first_fifty = array_slice($words, 0, 50); $remaining = array_slice($words, 50); }