現在以下のようにしてアーカイブおよび管理画面上でもカスタムフィールド「post_order」の数値でソートされています。
php
1function test_pre_get_posts($query) { 2 $query->set( 'post_type', 'custompostname'); 3 $query->set( 'meta_key', 'post_order' ); 4 $query->set( 'orderby', 'meta_value_num' ); 5 $query->set( 'order', 'ASC' ); 6} 7add_action( 'pre_get_posts', 'test_pre_get_posts' );
ただ、カスタム投稿の記事ページにて表示させている次へ・前へのリンク先が思うようにいかず、通常の時系列のものが表示されてしまいます。
php
1$prevpost = get_previous_post(true, '', 'custompostname'); //前の記事 2$nextpost = get_next_post(true, '', 'custompostname'); //次の記事
このように前後の記事を取得して、いろいろといじって表示させようとおもい失敗しています。
なにか方法はないものでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/16 13:44