示例#1
0
 /**
  * @param CustomPostType $post
  * @param array $args
  * @return array|bool|null
  */
 public function getPosts(CustomPostType $post, $args = [])
 {
     $args = array_merge(['numberposts' => -1, 'post_type' => $post->getBindingName()], $args);
     return $this->posts($args, get_class($post));
 }
示例#2
0
 public function belongsToPost(CustomPostType $post, $many = false)
 {
     return function () use(&$post, $many) {
         $terms = $post->terms($this->getTaxonomy(), true, get_class($this));
         if ($many) {
             return $terms;
         }
         if (count($terms) > 0) {
             return $terms[0];
         }
         return null;
     };
 }