お世話になります。
行き詰ってしまいどうにかお助けください。
WordPressの投稿画面で投稿公開時に抜粋が空欄の場合、特定のカスタムフィールドの値と
投稿本文の一部を抜粋に自動で入れようとしています。
スキルが無いので無駄が多いと思いますが、以下の方法を試みましたところ
新規投稿時には投稿本文は抜粋に入るのですが、カスタムフィールドが入りません。
function my_post_exp($text) { if (isset($_POST{"content"})) { if ($text == '') { $text = preg_replace('/<br \/>|<br>/', '', $_POST['content']); $text = strip_tags($text); $text = str_replace(array("\r\n","\n","\r"," "), '',$text); $text0 = post_custom('cf0', true); $text1 = $text0 .post_custom('cf1', true); $text2 = $text1 .post_custom('cf2', true); $text3 = $text2 .post_custom('cf3', true); $text4 = $text3 .post_custom('cf4', true); $text5 = $text4 .post_custom('cf5', true); $text6 = $text5 .post_custom('cf6', true); $text7 = $text6 .post_custom('cf7', true); $text8 = $text7 .post_custom('cf8', true); $text9 = $text8 .post_custom('cf9', true); $text = $text9.mb_substr($text, 0, 100, 'UTF-8'); } } return $text; } add_filter('excerpt_save_pre', 'my_post_exp');
投稿公開後に抜粋を空にしてから更新ボタンを押すと希望通りになるのですが
どうすれば最初の投稿時に両方入れることができますでしょうか。
よろしくお願い致します。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/04/18 16:05
2017/04/18 16:09
退会済みユーザー
2017/04/19 00:58
2017/04/19 11:54 編集
退会済みユーザー
2017/04/19 11:52