반응형
커스텀 필드로 투고를 주문하다
이 쿼리를 사용하고 있습니다.
$numposts = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=5&showposts='.$numposts.'&paged=' . $paged);
커스텀 필드별로 투고를 정렬하는 방법
어때?
$customfield = "MyCustomFieldName";
$numposts = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=5&showposts='.$numposts.'&paged='.$paged.'&meta_key='.$customfield.'&
orderby=meta_value&order=DESC');
또는 커스텀 필드를 유지하기 위해 새 변수를 생성하는 대신 쿼리에 직접 추가합니다.
query_posts('cat=5&showposts='.$numposts.'&paged='.$paged.'&meta_key=mycustomfield&
orderby=meta_value&order=DESC')
http://www.dyasonhat.com/plugins/wp-smart-sort/ 에 플러그인을 사용했습니다.
언급URL : https://stackoverflow.com/questions/4076000/order-posts-by-custom-field
반응형
'programing' 카테고리의 다른 글
ng-include 노드를 템플릿으로 바꾸시겠습니까? (0) | 2023.03.13 |
---|---|
Redux Reducer에서 스토어의 초기 상태 확인 (0) | 2023.03.13 |
react를 사용하여 x초마다 API 폴링 (0) | 2023.03.13 |
인증된 CORS 요청의 비행 전 OPTIONS 요청은 왜 Chrome에서는 작동하지만 Firefox에서는 작동하지 않습니까? (0) | 2023.03.13 |
스프링 nullable 주석이 알 수 없는 열거 상수 경고를 생성합니다. (0) | 2023.03.13 |