Making WordPress.org


Ignore:
Timestamp:
09/28/2022 11:18:13 PM (4 years ago)
Author:
adamwood
Message:

Learn: Sync with git WordPress/learn@f49e45d

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/archive-course.php

    r11697 r12096  
    2121
    2222        <section>
    23                 <div class="row align-middle between section-heading section-heading--with-space">
    24                         <?php the_archive_title( '<h1 class="section-heading_title h2">', '</h1>' ); ?>
     23                <div class="row align-middle between section-heading section-heading--with-space gutters">
     24                        <?php the_archive_title( '<h1 class="section-heading_title h2 col-8">', '</h1>' ); ?>
    2525                        <?php get_template_part( 'template-parts/component', 'archive-search' ); ?>
    2626                </div>
    … …  
    2828                <hr>
    2929
    30                 <div class="card-grid card-grid_2">
    3130                        <?php if ( have_posts() ) : ?>
    3231                                <?php while ( have_posts() ) :
    3332                                        the_post();
    3433
    35                                         $display_category_header = false;
    36                                         $categories = get_the_terms( get_the_ID(), 'course-category' );
     34                                        $prev_category;
     35                                        $begin_new_category = false;
     36                                        $categories         = get_the_terms( get_the_ID(), 'course-category' );
     37
    3738                                        if ( isset( $categories[0] ) ) {
    38                                                 $category_title = $categories[0]->name;
     39                                                $category_title       = $categories[0]->name;
    3940                                                $category_description = $categories[0]->description;
    40                                                 if ( $category_title != $prev_category ) {
    41                                                         $display_category_header = true;
    42                                                         $prev_category = $category_title;
    43                                                 }
     41                                                $begin_new_category   = $category_title !== $prev_category;
    4442                                        }
    4543
    46                                         if ( $display_category_header ) {
    47                                                 echo '<h2 class="h4 course-category-header">' . esc_html( $category_title ) . '</h2>';
     44                                        if ( $begin_new_category ) {
     45                                                // Close the previous card-grid if there was a previous category
     46                                                if ( ! empty( $prev_category ) ) {
     47                                                        echo '</div>';
     48                                                }
     49                                                ?>
     50                <h2 class="h4 course-category-header"><?php echo esc_html( $category_title ); ?></h2>
     51                                                <?php
    4852                                                if ( $category_description ) {
    4953                                                        echo '<div class="course-category-description">' . esc_html( $category_description ) . '</div>';
    5054                                                }
     55                                                ?>
     56                <div class="card-grid card-grid_2">
     57                                                <?php
     58                                                $prev_category = $category_title;
    5159                                        }
    5260
    … …  
    5765                                        );
    5866                                endwhile; ?>
     67                </div>
    5968                        <?php else : ?>
    6069                                <?php get_template_part( 'template-parts/content', 'none' ); ?>
    6170                        <?php endif; ?>
    62                 </div>
    6371
    6472                <?php the_posts_pagination(); ?>
Note: See TracChangeset for help on using the changeset viewer.