示例#1
1
 function ciGetPostsOfType($postType = 'post', $maxCharLength = -1, $featuredImageSize = array(1000, 1000), $maxNumPosts = 100, $orderBy = 'date', $order = ORDER_ASC)
 {
     $query = new WP_Query("showposts={$maxNumPosts}&post_type={$postType}&orderby={$orderBy}&order={$order}");
     $postsArray = array();
     while ($query->have_posts()) {
         $query->next_post();
         $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), $featuredImageSize);
         $maybeExcerpt = has_excerpt($query->post->ID) ? get_post_field('post_excerpt', $query->post->ID) : $query->post->post_content;
         $postsArray[] = array('id' => $query->post->ID, 'content' => apply_filters('the_content', ciFilterToMaxCharLength($maybeExcerpt, $maxCharLength)), 'fullContent' => apply_filters('the_content', $query->post->post_content), 'title' => $query->post->post_title, 'imgURL' => $attachment ? $attachment[0] : '', 'imgWidth' => $attachment ? $attachment[1] : -1, 'imgHeight' => $attachment ? $attachment[2] : -1, 'url' => get_permalink($query->post->ID));
     }
     wp_reset_postdata();
     return $postsArray;
 }
示例#2
1
 function ciGetAllStaff($maxNumEmployees = 100, $maxCharLength = -1)
 {
     $query = new WP_Query('showposts=' . $maxNumEmployees . '&post_type=' . CI_STAFF_TYPE);
     $employeeArray = array();
     while ($query->have_posts()) {
         $query->next_post();
         $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), CI_STAFF_IMG);
         $maybeExcerpt = has_excerpt($query->post->ID) ? $query->post->post_excerpt : $query->post->post_content;
         $employeeArray[] = array('id' => $query->post->ID, 'content' => ciFilterToMaxCharLength($maybeExcerpt, $maxCharLength), 'fullContent' => $query->post->post_content, 'title' => $query->post->post_title, 'imgURL' => $attachment ? $attachment[0] : '', 'imgWidth' => $attachment ? $attachment[1] : -1, 'imgHeight' => $attachment ? $attachment[2] : -1, 'url' => get_permalink($query->post->ID), 'socialURLs' => function_exists('ciGetStaffSocialURLs') ? ciGetStaffSocialURLs($query->post->ID) : array());
     }
     wp_reset_postdata();
     return $employeeArray;
 }