function get_other_projects($number_to_display = 8, $slice_index = 1)
 {
     $args = array();
     if ($this->meta_other_projects) {
         $project_type = get_term($this->meta_other_projects, 'gp-project-type');
         if ($project_type) {
             $args['gp-project-type'] = $project_type->slug;
         }
     }
     $all = gp_query_portfolio($args);
     wp_reset_query();
     $count = count($all);
     // if we don't have enough projects, return all
     if ($count <= $number_to_display) {
         return self::posts_to_projects($all);
     }
     $current_project_index = false;
     foreach ($all as $index => $project) {
         if ($this->post->ID == $project->ID) {
             $current_project_index = $index;
             break;
         }
     }
     // if we can't find current project, return first $number_to_display
     if ($current_project_index === false) {
         return self::posts_to_projects(array_slice($all, 0, $number_to_display));
     }
     if ($current_project_index + $number_to_display > $count) {
         /**
          * Means that our current project is in the last N.
          * Let's return last N.
          */
         return self::posts_to_projects(array_slice($all, $count - $number_to_display));
     }
     $slice_offset = $current_project_index - $slice_index;
     if ($slice_offset < 0) {
         $slice_offset = 0;
     }
     return self::posts_to_projects(array_slice($all, $slice_offset, $number_to_display));
 }
예제 #2
0
*/
gp_add_html_class('horizontal-page');
get_header();
?>
<div id="main" class="site site-with-sidebar">
    <div id="content" class="site-content">
        <div class="portfolio-list horizontal-content"><?php 
if (is_page()) {
    /**
     * We are on index page.
     * Let's modify main loop to gp_portfolio post type.
     *
     * If is_page() is false, then we are on taxonomy-gp-project-type.php
     * template, so our loop is already correct.
     */
    gp_query_portfolio();
}
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $project = new PortfolioProject(get_the_ID());
        $featured = $project->get_featured_media();
        if (!$featured) {
            continue;
        }
        // We have no media on this project, nothing to show.
        $attr['class'] = 'horizontal-item project';
        if ($featured->is_image()) {
            $image = $featured->get_image_data('gp-max');
        } else {
            $image = $featured->get_video_thumbnail('gp-max');