Last active
August 29, 2015 14:00
-
-
Save alenabdula/11235805 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
if ( ! function_exists('physicians_custom_post_type') ) { | |
// Register Custom Post Type | |
function physicians_custom_post_type() { | |
$labels = array( | |
'name' => 'Physicians', | |
'singular_name' => 'Physician', | |
'menu_name' => 'Physicians', | |
'parent_item_colon' => 'Parent Physician:', | |
'all_items' => 'All Physicians', | |
'view_item' => 'View Physician', | |
'add_new_item' => 'Add New Physician', | |
'add_new' => 'Add New', | |
'edit_item' => 'Edit Physician', | |
'update_item' => 'Update Physician', | |
'search_items' => 'Search Physician', | |
'not_found' => 'Not found', | |
'not_found_in_trash' => 'Not found in Trash', | |
); | |
$args = array( | |
'label' => 'physicians', | |
'description' => 'Custom Physicians Post Type', | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ), | |
'taxonomies' => array( 'department', 'location' ), | |
'hierarchical' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_nav_menus' => true, | |
'show_in_admin_bar' => true, | |
'menu_position' => 5, | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'capability_type' => 'page', | |
); | |
register_post_type( 'physicians', $args ); | |
} | |
// Hook into the 'init' action | |
add_action( 'init', 'physicians_custom_post_type', 0 ); | |
} | |
if ( ! function_exists( 'department_custom_taxonomy' ) ) { | |
// Register Custom Taxonomy | |
function department_custom_taxonomy() { | |
$labels = array( | |
'name' => 'Departments', | |
'singular_name' => 'Department', | |
'menu_name' => 'Departments', | |
'all_items' => 'All Departments', | |
'parent_item' => 'Parent Department', | |
'parent_item_colon' => 'Parent Department:', | |
'new_item_name' => 'New Department Name', | |
'add_new_item' => 'Add Department Item', | |
'edit_item' => 'Edit Department', | |
'update_item' => 'Update Department', | |
'separate_items_with_commas' => 'Separate departments with commas', | |
'search_items' => 'Search Departments', | |
'add_or_remove_items' => 'Add or remove departments', | |
'choose_from_most_used' => 'Choose from the most used departments', | |
'not_found' => 'Not Found', | |
); | |
$args = array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'show_in_nav_menus' => true, | |
'show_tagcloud' => true, | |
); | |
register_taxonomy( 'department', array( 'physicians' ), $args ); | |
} | |
// Hook into the 'init' action | |
add_action( 'init', 'department_custom_taxonomy', 0 ); | |
} | |
if ( ! function_exists( 'location_custom_taxonomy' ) ) { | |
// Register Custom Taxonomy | |
function location_custom_taxonomy() { | |
$labels = array( | |
'name' => 'Locations', | |
'singular_name' => 'Location', | |
'menu_name' => 'Locations', | |
'all_items' => 'All Locations', | |
'parent_item' => 'Parent Location', | |
'parent_item_colon' => 'Parent Location:', | |
'new_item_name' => 'New Location Name', | |
'add_new_item' => 'Add New Location', | |
'edit_item' => 'Edit Location', | |
'update_item' => 'Update Location', | |
'separate_items_with_commas' => 'Separate locations with commas', | |
'search_items' => 'Search Locations', | |
'add_or_remove_items' => 'Add or remove locations', | |
'choose_from_most_used' => 'Choose from the most used locations', | |
'not_found' => 'Not Found', | |
); | |
$args = array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'show_in_nav_menus' => true, | |
'show_tagcloud' => true, | |
); | |
register_taxonomy( 'location', array( 'physicians' ), $args ); | |
} | |
// Hook into the 'init' action | |
add_action( 'init', 'location_custom_taxonomy', 0 ); | |
} |
This file contains hidden or 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 | |
/** | |
* http://css-tricks.com/forums/topic/wordpress-question-about-tagging-logic | |
* | |
*/ | |
$post_terms = wp_get_object_terms($post->ID, 'department', array('fields'=>'ids')); | |
$currentID = get_the_ID(); | |
$args = array( | |
'post_type' => 'physician', | |
'post__not_in' => array($currentID), | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'department', | |
'field' => 'id', | |
'terms' => $post_terms | |
) | |
) | |
); | |
$the_query = new WP_Query($args); | |
?> | |
<h3>Cardiology Physicians</h3> | |
<?php if($the_query->have_posts()): while($the_query->have_posts()): $the_query->the_post(); ?> | |
<div class="profile-item"> | |
<div class="name"> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><strong><?php the_title(); ?></strong> <?php echo get_field('title'); ?></a> | |
</div> | |
<div class="thumb"> | |
<?php $image = wp_get_attachment_image_src(get_field('image'), 'physician-thumb'); ?> | |
<img src="<?php echo $image[0]; ?>" alt=""> | |
</div> | |
</div> | |
<?php endwhile; endif; wp_reset_postdata(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment