Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter digitaldeath

    (@digitaldeath)

    Thanks.
    Here’s my implemented solution:

    // Get the names (terms) of all departments
        $terms = get_terms("departments");
    
        // How many departments?
        $count = count($terms);
    
        if ($count > 0) {
            $div_counter = 0;
    
            // For each department, do the following
            foreach ($terms as $term) {
    
                // We don't want to generate duplicate output for certain departments, so we filter those out.
                if (($term->slug != 'executive-board') && ($term->slug != 'scientific-and-technical-board') &&
                    ($term->slug != 'managers'))
                {
    
                    // Determine if this section should be placed in the left or right column
    
                    $div_counter += 1;
                    if (($div_counter % 2) == 1) { // Odd number - right column
                        ?><div class="people-right-column"><?php
    
                    } else {
                        ?><div class="people-left-column"><?php  // Even number - left column
                    }
    
                    // Print the department name
                    echo "<h4 class=\"dept-title\">" . $term->name . "</h4>";
    
                    // Check to see what posts are tagged with the current department name (term) - the current department name is known as we're inside the loop here.
                    $args = array('post_type' => 'people', 'taxonomy' => 'departments', 'term' => $term->name, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC');
                    $loop = new WP_query($args);
    
                    // While there are posts within the current department term, do something with the post (display required information etc.)
                    while ($loop->have_posts()) : $loop->the_post();
                        ?>
                        <div class="profile-preview">
    
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> (<?php the_field('title'); ?>)
                            <?php
                                 the_excerpt();
                            ?>
                        </div>
                            <?php endwhile; ?></div><?php
                }
            }
        }
    ?>

    WP Alchemy is the way to go for now.

    +1, I’d love to be able to grab the code too.

Viewing 3 replies - 1 through 3 (of 3 total)