Making WordPress.org

Changeset 1113


Ignore:
Timestamp:
01/09/2015 01:47:26 AM (10 years ago)
Author:
iandunn
Message:

Central Theme: Group wordcamps on the Past WordCamps template by year.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/functions.php

    r1106 r1113  
    607607        }
    608608    }
     609
     610    /**
     611     * Group an array of WordCamps by year
     612     *
     613     * @param array $wordcamps
     614     *
     615     * @return array
     616     */
     617    public static function group_wordcamps_by_year( $wordcamps ) {
     618        $grouped_wordcamps = array();
     619
     620        foreach ( $wordcamps as $wordcamp ) {
     621            if ( $year = date( 'Y', get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true ) ) ) {
     622                $grouped_wordcamps[ $year ][] = $wordcamp;
     623            }
     624        }
     625
     626        return $grouped_wordcamps;
     627    }
    609628}
    610629
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/style.css

    r1105 r1113  
    15031503}
    15041504
     1505#content h3.wc-schedule-year {
     1506    margin-bottom: 8px;
     1507    font-size: 2em;
     1508    color: #028DB9;
     1509}
     1510
    15051511.wc-schedule .wc-schedule-list li {
    15061512    border-top: 1px #ececec solid;
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/template-past-wordcamps.php

    r1110 r1113  
    3535                                'compare'    => '<'
    3636                            ) )
    37                         ) ) 
     37                        ) )
    3838                    ) :
     39                        global $wcpt_template;
     40                        $wordcamps = WordCamp_Central_Theme::group_wordcamps_by_year( $wcpt_template->posts );
    3941                    ?>
    4042
    41                     <ul class="wc-schedule-list">
    42                     <?php while ( wcpt_wordcamps() ) : wcpt_the_wordcamp(); ?>
    43                        
    44                         <li>
    45                             <a href="<?php echo esc_url( wcpt_get_wordcamp_url() ); ?>">
    46                                 <?php if ( has_post_thumbnail() ) : ?>
    47                                     <?php the_post_thumbnail( 'wccentral-thumbnail-past', array( 'class' => 'wc-image' ) ); ?>
    48                                 <?php else : ?>
    49                                     <div class="wc-image wp-post-image past-wordcamp-placeholder-thumb" title="<?php the_title(); ?>"></div>
    50                                 <?php endif; ?>
    51                                
    52                                
    53                                 <h2 class="wc-title"><?php wcpt_wordcamp_title(); ?></h2>
    54                                 <span class="wc-country"><?php wcpt_wordcamp_location(); ?></span>
    55                                 <span class="wc-date">
    56                                
    57                                 <?php WordCamp_Central_Theme::the_wordcamp_date(); ?>,
    58                                 <?php wcpt_wordcamp_start_date( 0, 'Y' ); ?>
    59                                    
    60                                 </span>
    61                             </a>
    62                         </li>
     43                    <?php foreach ( $wordcamps as $year => $posts ) : ?>
     44                        <h3 class="wc-schedule-year"><?php echo esc_html( $year ); ?></h3>
    6345
    64                     <?php endwhile; // wcpt_wordcamps ?>
    65                 </ul>
     46                        <ul class="wc-schedule-list">
     47                            <?php foreach ( $posts as $post ) : setup_postdata( $post ); ?>
     48
     49                                <li>
     50                                    <a href="<?php echo esc_url( wcpt_get_wordcamp_url() ); ?>">
     51                                        <?php if ( has_post_thumbnail() ) : ?>
     52                                            <?php the_post_thumbnail( 'wccentral-thumbnail-past', array( 'class' => 'wc-image' ) ); ?>
     53                                        <?php else : ?>
     54                                            <div class="wc-image wp-post-image past-wordcamp-placeholder-thumb" title="<?php the_title(); ?>"></div>
     55                                        <?php endif; ?>
     56
     57                                        <h2 class="wc-title"><?php wcpt_wordcamp_title(); ?></h2>
     58                                        <span class="wc-country"><?php wcpt_wordcamp_location(); ?></span>
     59
     60                                        <span class="wc-date">
     61                                            <?php WordCamp_Central_Theme::the_wordcamp_date(); ?>,
     62                                            <?php wcpt_wordcamp_start_date( 0, 'Y' ); ?>
     63                                        </span>
     64                                    </a>
     65                                </li>
     66
     67                            <?php endforeach; ?>
     68                        </ul>
     69                    <?php wp_reset_postdata(); endforeach; ?>
     70
    6671                <a href="<?php echo home_url( '/schedule/' ); ?>" class="wc-schedule-more"><span class="arrow">&larr;</span> Upcoming WordCamps</a>
    6772
Note: See TracChangeset for help on using the changeset viewer.