__( 'CCO Edition', 'ccoarchive' ), 'all_items' => __( 'All CCO Editions', 'ccoarchive' ), 'add_new_item' => __( 'Add New CCO Edition', 'ccoarchive' ), 'edit_item' => __( 'Edit Edition', 'ccoarchive' ), 'new_item' => __( 'New CCO Edition', 'ccoarchive' ), 'view_item' => __( 'View Edition', 'ccoarchive' ), 'search_item' => __( 'Search CCO Editions', 'ccoarchive' ), 'not_found' => __( 'No CCO Editions found', 'ccoarchive' ), 'not_found_in_trash' => __( 'No CCO Editions found in trash', 'ccoarchive' ), ); $args = array( 'label' => __( 'CCO Archive', 'ccoarchive' ), 'labels' => $labels, 'public' => true, 'menu_position' => 5, 'supports' => array( 'title', 'author', 'thumbnail', 'revisions', ), 'taxonomies' => array( 'category', 'post-tag' ), 'has_archive' => true, 'rewrite' => array( 'slug' => 'ccoarchive/edition', 'with_front' => false, ), ); register_post_type( 'ccoarchive_post', $args ); } /** * Fire the register function on WP init */ add_action( 'init', 'ccoarchive_register_cpt' ); /** * Create, format and output the CCO edition archive listing */ function ccoarchive_gen_table() { //Build the argument list for the query $args = array( 'post_type' => 'ccoarchive_post', 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'DESC' ); //Reset default query and create a new one with arg $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query($args); //Only do something if there's actually CCO editions to act on if($wp_query->have_posts()) { //Set up the container row $cco_output .= '
'; //The Loop... while($wp_query->have_posts()) { $wp_query->the_post(); //Get CCO edition metadata $cco_meta = get_post_meta( get_the_ID() ); //Get CCO edition featured image $cco_image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); //Put it all together per edition $cco_output .= '
'; $cco_output .= '
' . escape_output($cco_meta['edmonth'][0]) . ' ' . escape_output($cco_meta['edyear'][0]) . '
'; $cco_output .= 'CCO_cover_image'; $cco_output .= '
'; } //Close the container $cco_output .= '
'; } else { //This should never happen! echo '-'; } //Reset the query so WP can continue normally wp_reset_query(); //Return the output return $cco_output; } /** * Shortcode to add in any page that we need the archive listing */ add_shortcode( 'cco_archive_table_html', 'ccoarchive_gen_table');