Quantcast
Viewing latest article 9
Browse Latest Browse All 46

Intuitive Custom Post Order ver.3.0.8 リリースノート


Plugin URL

WordPress Plugin Directory URI

Changelog

= 3.0.8 =
* Even for ‘get_posts()’, Your custom Query which uses the ‘order’ or ‘orderby’ parameters is preferred.
ATTENTION: Only if you use ‘get_posts()’ to re-overwrite to the default order( orderby=date, order=DESC ), You need to use own custom parameter ‘orderby=default_date’.

get_posts() を使った並び順の上書き

並び替えを有効にしているオブジェクトは、なにも指定しなくても、管理画面の並び順とフロント画面の並び順が一致します。
ここで、フロント側だけあえて並び順を変更したい場合は、orderby と order パラメーターを明示的に指定したクエリを発行すれば、そちらが優先されます。
これまで WP_Query, pre_get_posts, query_posts() には対応していましたが、唯一 get_posts() には対応していませんでした。
それを今回のアップデートで対応しました。

get_posts() でもテンプレート側で以下のように指定すれば、並び順が上書きされます。

<?php $query = get_posts( array(
	'orderby' => 'title',
) ) ?>

ただし、デフォルトの並び順(orderby=date, order=DESC)に上書きするためには、独自のパラメーター default_date を指定する必要があることに注意してください。
これは get_posts() を使う場合のみの注意点です。

<?php $query = get_posts( array(
	'orderby' => 'default_date',
	'order' => 'DESC',
) ) ?>

Viewing latest article 9
Browse Latest Browse All 46

Trending Articles