Last active
August 29, 2015 14:15
-
-
Save samediamba/6c9d14529cf9e1ed2077 to your computer and use it in GitHub Desktop.
Sample Staff Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Do not include opening PHP tag | |
*/ | |
//* Remove the entry meta in the entry header | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
/* MY CUSTOM FUNCTIONS */ | |
/** | |
* [Dashboard] Add Genre Taxonomy to columns at http://example.com/wp-admin/edit.php?post_type=books | |
* URL: http://make.wordpress.org/core/2012/12/11/wordpress-3-5-admin-columns-for-custom-taxonomies/ | |
*/ | |
/* add_filter( 'manage_taxonomies_for_books_columns', 'books_columns' ); | |
function books_columns( $taxonomies ) { | |
$taxonomies[] = 'genre'; | |
return $taxonomies; | |
} */ | |
//* [All Staff pages] Function to display values of custom fields (if not empty) | |
function sk_display_custom_fields() { | |
$postid = get_the_ID(); | |
$surname = get_field( 'surname' ); | |
$position = get_the_excerpt(); | |
$role = get_field( 'role' ); | |
$phone_number = get_field( 'phone_number' ); | |
$email_address = get_field( 'email_address' ); | |
$skype_address = get_field( 'skype_address' ); | |
$residence = get_field( 'residence' ); | |
$facebook = get_field( 'facebook' ); | |
$twitter = get_field( 'twitter' ); | |
$google = get_field( 'google' ); | |
$linkedin = get_field( 'linkedin' ); | |
$occupation_type = get_field( 'occupation_type' ); | |
$name_of_institution = get_field( 'name_of_institution' ); | |
$area_of_study = get_field( 'area_of_study' ); | |
$place_of_work = get_field( 'place_of_work' ); | |
$job_description = get_field( 'job_description' ); | |
/* | |
Add a custom field excerpt | |
Courtesy: https://wordpress.org/support/topic/how-to-pull-excerpt-from-advanced-custom-field | |
*/ | |
function custom_field_excerpt() { | |
global $post; | |
$text = $position; | |
if ( '' != $text ) { | |
$text = strip_shortcodes( $text ); | |
$text = apply_filters('the_content', $text); | |
$text = str_replace(']]>', ']]>', $text); | |
$excerpt_length = 100; // 100 words | |
$excerpt_more = ' ...'; | |
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); | |
} | |
return apply_filters('the_excerpt', $text); | |
} //* End of custom field excerpt */ | |
/* Display the Custom field excerpt */ | |
/* echo custom_field_excerpt();*/ | |
echo '<p>'; /*General Details and the Image*/ | |
/*General Details */ | |
if ( $surname|| $position || $role|| $phone_number || $email_address|| $skype_address ) { | |
echo '<strong>Position: </strong>' . $position. '<br>'; | |
//*echo '<strong>The Staff Post ID is: </strong>' . $postid. '<br>';*/ | |
if ( $email_address|| $skype_address) { | |
echo '<h4 class="staff-section-title">Contact Info.</h4>';/*The Biography Area*/ | |
} | |
if ( $email_address ) { | |
echo '<strong>Email Address</strong>: ' . $email_address . '<br>'; | |
} | |
if ( $skype_address ) { | |
echo '<strong>Skype Address</strong>: ' . $skype_address . '<br>'; | |
} | |
} | |
echo '</p>'; | |
/*Display Social Media Links */ | |
echo '<p>'; | |
if ( $facebook || $twitter || $google || $linkedin ) { | |
echo '<h4 class="staff-section-title">Find ' . $surname . ' on Social Media </h4>'; | |
echo '<ul> '; | |
if ( $facebook ) { | |
echo '<li> <a href=" ' . $facebook . ' " target="_blank">Facebook</a></li>'; | |
} | |
if ( $twitter ) { | |
echo '<li> <a href=" ' . $twitter . ' " target="_blank">Twitter</a></li>'; | |
} | |
if ( $google ) { | |
echo '<li> <a href=" ' . $google . ' " target="_blank">Google + </a></li>'; | |
} | |
if ( $linkedin ) { | |
echo '<li> <a href=" ' . $linkedin . ' " target="_blank">LinkedIn</a></li>'; | |
} | |
echo '</ul> '; | |
} | |
echo '</p>'; | |
add_action( 'genesis_entry_content', 'sk_show_featured_image_single_posts', 9 ); | |
/** | |
* Display the Staff Photo, floated to the Right | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/how-to-display-featured-image-in-single-posts-in-genesis/ | |
*/ | |
function sk_show_featured_image_single_posts() { | |
if ( ! is_singular( 'staff' ) ) { | |
return; | |
} | |
$image_args = array( | |
'size' => 'medium', | |
'attr' => array( | |
'class' => 'alignright', | |
), | |
); | |
genesis_image( $image_args ); | |
} | |
echo '</p>'; /*This completes the General Details and the Image*/ | |
if ( $name_of_institution || $area_of_study || $place_of_work || $job_description ) { | |
echo '<h4 class="staff-section-title">Roles and Responsibilities</h4>';/*The Biography Area*/ | |
echo $role; | |
switch ($occupation_type) { | |
case "Student": | |
echo '<h4 class="staff-section-title">Study Life </h4>' . $surname . ' is a '. $area_of_study .' student at '. $name_of_institution .' '; | |
break; | |
case "Worker": | |
echo '<h4 class="staff-section-title">Occupation</h4>' . $surname . ' serves as the '. $job_description .' at '. $place_of_work .' '; | |
break; | |
} | |
} | |
} /* Finish displaying custom fields */ | |
//* [All Staff pages] Show Genre custom taxonomy terms for Staff CPT single pages, archive page and Church Department taxonomy term pages | |
add_filter( 'genesis_post_meta', 'custom_post_meta' ); | |
function custom_post_meta( $post_meta ) { | |
if ( is_singular( 'staff' ) || is_post_type_archive( 'staff' ) || is_tax( 'church_department' ) ) { | |
$post_meta = '[post_terms taxonomy="church_department" before="Department: "]'; | |
} | |
return $post_meta; | |
} /* Custom Post Meta */ | |
/** | |
* [All Staff pages] Display Post meta only if the entry has been assigned to any Church Department term | |
* Removes empty markup, '<p class="entry-meta"></p>' for entries that have not been assigned to any Genre | |
*/ | |
function sk_custom_post_meta() { | |
if ( has_term( '', 'church_department' ) ) { | |
genesis_post_meta(); | |
} | |
} | |
/** | |
* [WordPress] Template Redirect | |
* Use archive-staff.php for Church Department taxonomy archives. | |
*/ | |
add_filter( 'template_include', 'sk_template_redirect' ); | |
function sk_template_redirect( $template ) { | |
if ( is_tax( 'church_department' ) ) | |
$template = get_query_template( 'archive-staff' ); | |
return $template; | |
} | |
add_action( 'genesis_entry_content', 'sk_show_featured_image_single_staff_pages', 9 ); | |
/** | |
* Display Featured Image floated to the right in single Posts. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/how-to-display-featured-image-in-single-posts-in-genesis/ | |
*/ | |
function sk_show_featured_image_single_staff_pages() { | |
$image_args = array( | |
'size' => 'medium', | |
'attr' => array( | |
'class' => 'alignright', | |
), | |
); | |
genesis_image( $image_args ); | |
} | |
add_action( 'genesis_entry_content', 'sk_display_custom_fields' ); | |
/** | |
* One line description with a period at the end. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/ | |
*/ | |
/* | |
Related posts for CPT by custom taxonomy | |
Courtesy: http://isabelcastillo.com/related-custom-post-type-taxonomy | |
*/ | |
//* Previous and Next Post navigation | |
add_action('genesis_entry_footer', 'sk_custom_post_nav'); | |
function sk_custom_post_nav() { | |
/*echo '<div class="prev-next-post-links">'; | |
previous_post_link('<div class="previous-post-link">« %link</div>', '<strong>%title</strong>' ); | |
next_post_link('<div class="next-post-link">%link »</div>', '<strong>%title</strong>' ); | |
echo '</div>';*/ | |
} | |
// Display Related Staff Profiles | |
get_template_part( 'related/related', 'staff' ); | |
/*add_action( 'genesis_after_header', 'sk_change_genesis_primary_sidebar' );*/ | |
/** | |
* Show custom Primary sidebar in Primary Sidebar location. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/ | |
*/ | |
/*function sk_change_genesis_primary_sidebar() { | |
if( is_active_sidebar( 'primary-sidebar-book' ) ) { | |
// Remove the Primary Sidebar from the Primary Sidebar area. | |
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); | |
add_action( 'genesis_sidebar', 'sk_do_sidebar' ); | |
} | |
} | |
function sk_do_sidebar() { | |
dynamic_sidebar( 'primary-sidebar-book' ); | |
}*/ | |
//* To remove empty markup, '<p class="entry-meta"></p>' for entries that have not been assigned to any Genre | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
/*add_action( 'genesis_entry_footer', 'sk_custom_post_meta' );*/ | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment