Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@electricbrick
Created June 26, 2014 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save electricbrick/3a2f6ab03f644ecbc071 to your computer and use it in GitHub Desktop.
Save electricbrick/3a2f6ab03f644ecbc071 to your computer and use it in GitHub Desktop.
<?php
/**
* Faculty Archive
*
*/
add_action('genesis_meta', 'faculty_styles');
function faculty_styles() {
wp_enqueue_style( 'faculty-css', get_stylesheet_directory_uri() . '/css/faculty.css');
}
# Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'su_faculty_taxonomy_archive_loop' );
function su_faculty_taxonomy_archive_loop() {
//this loop returns all faculty separated by departments they belong to
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // get current term
$parent = get_term($term->parent, get_query_var('taxonomy') ); // get parent term
$children = get_term_children($term->term_id, get_query_var('taxonomy')); // get children
$post_type = 'faculty';
$tax = 'department';
$tax_terms = get_terms($tax);
$image_args = array(
'size' => 'medium',
'attr' => array(
'class' => 'aligncenter',
),
);
if ($tax_terms) {
foreach ($tax_terms as $tax_term) {
$args=array(
'post_type' => $post_type,
"$tax" => $tax_term->slug,
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1,
'depth' => 2,
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '<h3 class="dept-title">' . $tax_term->name . '</h3>';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="faculty-entry">
<?php
$image = genesis_get_image( $image_args );
$position = get_field( '_faculty_position' );
if ( $image ) {
echo '<a href="' . get_permalink() . '">' . $image .'</a>';
} ?>
<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
<?php echo '<p>' . $position . '</p>'; ?>
<?php echo '</div>'; ?>
<?php
endwhile;
}
wp_reset_query();
}
}
}
//* Remove items from loop
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
//* Move Title below Image
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
add_action( 'genesis_entry_footer', 'genesis_entry_header_markup_open', 5 );
add_action( 'genesis_entry_footer', 'genesis_entry_header_markup_close', 15 );
add_action( 'genesis_entry_footer', 'genesis_do_post_title' );
//* Remove Archive Pagination
remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' );
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment