code atas


Get_Post_Meta Array カスタムフィールド


Get_Post_Meta Array カスタムフィールド. カスタムフィールドの値はpostmetaテーブル [1] に格納される。 postmetaテーブルの構造(フィールド) meta_id; Get_metadata () function get_post_meta( $post_id, $key = '', $single = false ) {.

[Wordpress]カスタムフィールドで設定した順番で記事を表示したい(入力編) Hiroki's toy box
[Wordpress]カスタムフィールドで設定した順番で記事を表示したい(入力編) Hiroki's toy box from www.blugrit.com

<?php $custom_posts = get_posts(array( 'post_type' => 'カスタム投稿タイプスラッグ', // 投稿タイプ 'posts_per_page' => 6, // 表示件数 'meta_key' => 'カスタムフィールドのキー', //並び替えに利用したいカスタムフィールドのキーを指定 'orderby' => 'meta_value', //カスタムフィールドの値で並び替え 'order' => 'asc' // 昇順・降順 ) )); $current_date = date_i18n( 'ymd' ); If(empty( $custom_fields ) === false){ ?> カスタムフィールドが入ってるときの処理.

「Wordpressでカスタムフィールドの条件を指定してカスタム投稿タイプの投稿を取得するにはどうしたらええんや」 っていう壁にぶち当たった話をします。 さぁ。 どうやって取んねん。 魔法の言葉、Get_Posts.


<?php $args = <strong>array</strong>( '<strong>post</strong>_type' => '<strong>post</strong>', '<strong>posts</strong>_per_page' => 10, // <strong>カスタムフィールド</strong>(数値のみ入力される<strong>フィールド</strong>) '<strong>meta</strong>_query' => <strong>array</strong>( 'customfield_01' => <strong>array</strong>( 'key' => 'customfield_01', 'type' => 'numeric' ), 'customfield_02' => <strong>array</strong>( 'key' => 'customfield_02', 'type' => 'numeric' ) ), 'orderby' => <strong>array</strong>( 'customfield_01' => 'desc', 'customfield_02' => 'asc' ) ); カスタムフィールドの値はpostmetaテーブル [1] に格納される。 postmetaテーブルの構造(フィールド) meta_id; Array ( 'hoge' => array ( 'foo' => 値;

Query_Posts ( Array ( 'Meta_Query' => Array ( Array ( 'Key'=>'Ranking', 'Value'=>'1' ) ) ) );


Get_metadata () の第1パラメータ(オブジェクトの種類 comment, post, term, user)に post を指定した実行結果を返しています。. 'meta_key' => '項目名', 'meta_value' => '値', カスタムフィールドの値を複数指定したい場合はこうなります。. $current_date = date_i18n( 'ymd' );

Get_Post_Meta ( $Post_Id, $Key, $Single );


Get_metadata () function get_post_meta( $post_id, $key = '', $single = false ) {. // カスタム投稿名 $post_type = 'seminar'; すべてのカスタムフィールド値を取得するには get_post_custom() を使うとよいでしょう。update_post_meta() や delete_post_meta()、add_post_meta()も参照してください。 使い方 <?php $meta_values = get_post_meta($post_id, $key, $single);

If(Empty( $Custom_Fields ) === False){ ?> カスタムフィールドが入ってるときの処理.


<?php $custom_posts = get_posts(array( 'post_type' => 'カスタム投稿タイプスラッグ', // 投稿タイプ 'posts_per_page' => 6, // 表示件数 'meta_key' => 'カスタムフィールドのキー', //並び替えに利用したいカスタムフィールドのキーを指定 'orderby' => 'meta_value', //カスタムフィールドの値で並び替え 'order' => 'asc' // 昇順・降順 ) ));

You have just read the article entitled Get_Post_Meta Array カスタムフィールド. You can also bookmark this page with the URL : https://valeriaokung.blogspot.com/2022/02/getpostmeta-array.html

Related Posts

0 Response to "Get_Post_Meta Array カスタムフィールド"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel