ループ内でthe_author();
関数を変更する方法を探しています。投稿したユーザーの名前でメタデータを投稿します。
私はこれをする必要があります:
the_author();
を表示しますが、表示されていない場合は投稿メタのデータを表示します。the_author()
なので、functionにはコールバック関数がありません。
アイデアは私のテーマのthe_author()
を置き換えることです。
the_author()
関数自体を変更する必要はありません。簡単なコンディショナルタグでうまくいくでしょう。例:
<?php
/*** on your functions.php file ***/
function ifRegistered() {
if(is_user_logged_in()) {
the_author();
} else {
echo get_the_post_meta($post->ID, 'your_post_meta_key', true);
// or anything else, of course
}
}
/*** on the template you want to use the function **/
// your HTML markup ...
ifRegistered();
// more possible HTML ...
?>
それが役立つことを願っています!
編集:機能を更新しました。