Skip to content

Instantly share code, notes, and snippets.

@tomfinitely
Created June 24, 2014 18:15
Show Gist options
  • Save tomfinitely/ab39721602f991307046 to your computer and use it in GitHub Desktop.
Save tomfinitely/ab39721602f991307046 to your computer and use it in GitHub Desktop.
<?php
/**
* Faculty Archive
*
*/
# Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
# Remove the breadcrumb
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
//* Add Portfolio Image
add_action( 'genesis_entry_content', 'su_faculty_image' );
function su_faculty_image() {
echo wpautop( genesis_get_image( array( 'size' => 'medium' ) ) );
}
//* Display As Columns
add_filter( 'post_class', 'su_faculty_post_class' );
function su_faculty_post_class( $classes ) {
$columns = 3;
$column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
$classes[] = $column_classes[$columns];
global $wp_query;
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
$classes[] = 'first';
return $classes;
}
add_action( 'genesis_before_loop', 'su_faculty_taxonomy_archive_loop' );
function su_faculty_taxonomy_archive_loop() {
/*
* Loop through Categories and Display Posts within
*/
$post_type = 'faculty';
// Get all the taxonomies for this post type
$post_id = null;
$taxonomies = get_object_taxonomies( array( 'post_type' => $post_type ) );
$taxonomy = 'department'; //change me
$term = get_query_var( 'term' );
$term_obj = get_term_by( 'slug' , $term , $taxonomy );
$position = get_field( '_faculty_position' );
foreach( $taxonomies as $taxonomy ) :
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy );
foreach( $terms as $term ) : ?>
<?php echo '<h3>' . $term->name . '</h3>'; ?>
<?php
$args = array(
'post_type' => $post_type,
'posts_per_page' => 50, //show all posts
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => array( $term_obj->slug ),
)
)
);
$posts = new WP_Query($args);
$columns = 3;
$column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
$classes[] = $column_classes[$columns];
if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post();
$classes[] = 'first';
return $classes; ?>
<?php if(has_post_thumbnail()) { ?>
<?php the_post_thumbnail(); ?>
<?php }
/* no post image so show a default img */
else {
echo wpautop( genesis_get_image( array( 'size' => 'medium' ) ) );
} ?>
<?php echo get_the_title(); ?>
<?php echo '<h5>' . $position . '</h5>'; ?>
<?php endwhile; endif; ?>
<?php endforeach;
endforeach;
}
//* 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