Skip to content

Instantly share code, notes, and snippets.

@derick-montague
Last active October 16, 2016 18:20
Show Gist options
  • Save derick-montague/43d55cae3585d474ca45 to your computer and use it in GitHub Desktop.
Save derick-montague/43d55cae3585d474ca45 to your computer and use it in GitHub Desktop.
Wordpress loops and other
<?php
// Adding custom posts
add_action('init', 'team_register');
function team_register() {
$labels = array(
'name' => _x('Team Members', 'post type general name'),
'singular_name' => _x('Team Member', 'post type singular name'),
'add_new' => _x('Add Team Member', 'Who Item'),
'add_new_item' => __('Add Team Members'),
'edit_item' => __('Edit Team'),
'new_item' => __('New Team Member'),
'view_item' => __('View Team Members'),
'search_items' => __('Search Team Members'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'show_ui' => true,
'query_var' => true,
//'menu_icon' => get_bloginfo('template_directory') . '/img/you_need_to_add_one.png',
'rewrite' => array('slug'=>'about','with_front'=>false),
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array('title','editor', 'excerpt', 'custom-fields','thumbnail','revisions','page-attributes')
);
register_post_type( 'team' , $args );
}
//register a custom taxonomy for who we are
add_action( 'init', 'create_team_taxonomies', 0);
//create taxonomy for team page sections
function create_team_taxonomies()
{
// Add new taxonomy, make it hierarchical (like categories)
register_taxonomy('team_type',array('team'), array(
'hierarchical' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'label' => 'Page Sections',
"singular_label" => "Page Section",
'show_ui' => true,
'query_var' => true,
'rewrite' => true
));
}
?>
<div class="media">
<?php
$args = array( 'post_type' => 'capability' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'post-home', true);
$thumb_url = $thumb_url_array[0];
?>
<div class="media--img"><img src="<?php echo $thumb_url; ?>" alt="" /></div>
<div class="media--content">
<h3><?php the_title() ;?></h3>
<p><?php echo the_excerpt(); ?></p>
<a class="button--dark" href="<?php the_permalink(); ?>">Learn More</a>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment