0

하위 페이지를 허용하는 이벤트의 사용자 정의 페이지 유형이 있으며 하위 페이지의 날짜 순서로 이벤트 페이지를 정렬하려고합니다.하위 페이지의 사용자 정의 필드를 기반으로 페이지 순서 지정

캠핑 여행 :

  • 텍사스 캠핑 여행 (날짜의 사용자 정의 필드 : 2014년 2월 12일)
  • 유타 캠핑 여행 (의 사용자 정의 필드

    나의 구조는 다음과 같은 것입니다 날짜 : 2014년 3월 10일)

모금 :

    ,451,515,
  • 빵을 판매 (날짜의 사용자 정의 필드 : 2014년 1월 30일)
  • 입찰 식 경매 (날짜의 사용자 정의 필드 : 2014년 5월 1일)

나는 것 페이지를 조회 모금 활동, 캠핑 여행 순으로 돌아갈 수 있습니다.

답변

0

나는 캠핑 여행을 분리하기 위해 카테고리를 사용하고 있다고 가정합니다. & 모금 행사이지만이 방법은 출장/기금 모금 행사를 분리하는 다른 방법과 비슷해야합니다. 또한 루프 밖에서 또는 보조 루프로이 작업을 수행하려고한다고 가정합니다. 나는 이것을 테스트하지는 않았지만 이것과 같은 것이 트릭을해야한다. 기본적으로 여기

는 할 거라고 것입니다 :

1) 모금과 캠핑 여행을 모두 쿼리, 날짜에 의해 명령했다.

2) 두 검색어를 병합하면 모금 행사가 먼저 이루어지고 캠핑이 두 번째로 진행됩니다.

3) 반환 된 각 게시물을 반복하고 원하는 정보를 마크 업하십시오.

코드 :

<?php //Enter your information for each variable: 
    $post_type = 'enter_your_custom_post_type_slug'; 
    $fundraiserCatID = 'enter_your_fundaiser_category_id'; 
    $campingCatID = 'enter_your_camping_category_id'; 
    $acfDateFieldName = 'enter_your_date_acf_field_slug'; 

    //Setup each Query args 
    $fundraiserAgrs = array('post_type' => $post_type, 'cat' => $fundraiserCatID, 'orderby' => 'meta_value', 'meta_key' => $acfDateFieldName, 'order' => 'ASC'); 
    $campingAgrs = array('post_type' => $post_type, 'cat' => $fundraiserCatID, 'orderby' => 'meta_value', 'meta_key' => $acfDateFieldName, 'order' => 'ASC'); 

    $fundraisers = get_posts($fundraiserArgs); 
    $campingTrips = get_posts($campingArgs); 

    $events = array_push($fundraisers, $campingTrips); //merge the two queries, with fundraisers first, then camping trips 

    if($events) : foreach($events as $event): //If we have $events, loop through each event 


     //Do what you will with the $event content ?> 

     <h1><?php echo $event->post_title; ?></h1> 
     <?php echo $event->post_content; ?> 
     <h6>Date: <?php the_field($acfDateFieldName, $event->ID); ?></h6> 

    <?php endforeach; endif; //End the loop and the conditional ?> 
관련 문제