標準のwp関数get_the_author_meta()にいくつか問題があります。著者のソーシャルリンクを表示するために私のプロジェクトで使っていますが、私はいつも空の変数を取得しています。ここでwpでget_the_author_meta()が動作しない
は、記事ページに私のコードです:
$author_name = get_the_author();//not empty
$author_info = get_the_author_meta('description');//not empty
$author_website = get_the_author_meta('url');//empty
$author_facebook = get_the_author_meta('facebook');//empty
$author_twitter = get_the_author_meta('twitter');//empty
$author_google = get_the_author_meta('google');//empty
$author_linkedin = get_the_author_meta('linkedin','7');//also empty whit this desperate attempt
$author_instagram = get_the_author_meta('instagram',7);//also empty whit this desperate attempt
私はすべての社会的なリンクを持つ著者の記事でテスト。 私はPHPにno jsエラーはありません。 cimyユーザーの追加フィールドをインストールしました。
最初に投稿者データをダンプして、最初にそのフィールドが存在するかどうかを確認してください。 – TurtleTread
のvar_dump(get_the_author_meta()); //文字列(0) "" \tのvar_dump(get_the_author_meta(7)); //文字列(0) "" \tのvar_dump(get_the_author_meta( '7')); //文字列( 0) "" 非常に厳しいのは、これらのフィールドがすべて存在し、DBでは空ではないということです。 –
プラグインを使用してこれらのソーシャルリンクを著者に追加しています。空の文字列を返すフィールドは、Codexでは有効ではありません。 https://codex.wordpress.org/Function_Reference/the_author_meta –