Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Template Name: Stories List
- * Description: Displays Professions with list of stories and link to custom taxonomy archive
- * Author: Marj Wyatt aka Virtually Marj
- *
- * Schema http://schema.org/ItemList
- */
- if ( !is_user_logged_in() ) {
- wp_redirect( home_url('/oops-this-content-is-members-only') );
- exit;
- }
- remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
- add_action( 'genesis_loop', 'vm_stories_archive' ); // Add custom loop
- //add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); // Force full page layout
- /*add_filter( 'genesis_attr_body', 'vm_list_schema' ); // Customize Schema Markup
- function vm_list_schema() {
- $attributes['itemtype'] = 'http://schema.org/ItemList';
- return $attributes;
- }*/
- function vm_stories_archive() {
- echo '<div class="cities">';
- $argsCity = array(
- 'smallest' => 16,
- 'largest' => 16,
- 'unit' => 'px',
- 'number' => 50,
- 'format' => 'flat',
- 'separator' => "·",
- 'orderby' => 'name',
- 'order' => 'ASC',
- 'exclude' => null,
- 'include' => null,
- 'topic_count_text_callback' => default_topic_count_text,
- 'link' => 'view',
- 'taxonomy' => 'city',
- 'echo' => true,
- 'child_of' => null, // see Note!
- );
- echo '<h4 class="widget-title">Peruse by City</h4>';
- wp_tag_cloud( $argsCity );
- echo '</div>';
- echo '<div class="states">';
- $argsState = array(
- 'smallest' => 16,
- 'largest' => 16,
- 'unit' => 'px',
- 'number' => 50,
- 'format' => 'flat',
- 'separator' => "·",
- 'orderby' => 'name',
- 'order' => 'ASC',
- 'exclude' => null,
- 'include' => null,
- 'topic_count_text_callback' => default_topic_count_text,
- 'link' => 'view',
- 'taxonomy' => 'state',
- 'echo' => true,
- 'child_of' => null, // see Note!
- );
- echo '<h4 class="widget-title">Peruse by State</h4>';
- wp_tag_cloud( $argsState );
- echo '</div>';
- echo '<p> </p>';
- echo '<div class="story-content" itemscope="itemscope" itemtype="http://schema.org/ItemList">';
- $profession_terms = get_terms( 'professions', array(
- 'orderby' => 'count',
- 'order' => 'DESC',
- 'hide_empty' => 0
- ) );
- foreach( $profession_terms as $term ) {
- $count = $term->count;
- $term_link = get_term_link( $term );
- $blogurl = get_bloginfo('url');
- // Define the query
- $args1 = array(
- 'posts_per_page' => -1,
- 'post_type' => 'shows',
- 'professions' => $term->slug
- );
- $myQuery = new WP_Query( $args1 );
- if ( $count == 1 ) {
- $label = 'Story'; }
- if ( ( $count > 1 ) || ( $count == 0 ) ) {
- $label = 'Stories';
- }
- echo '<h2 itemprop="name"><a href="' . $term_link .'">' . $term->name . '</a><span class="entry-meta"> (' . $count . ' ' . $label . ')</span></h2>';
- echo '<meta itemprop="itemListOrder" content="Unordered" />';
- if ( $count == 0 ) {
- echo '<p>No stories found.</p>';
- echo '<p class="postlist-entry-meta">Be the first to <a href="' . $blogurl . '/add-your-story/">add your <b>' . $term->name . '</b> story</a>!</p>';
- }
- while ( $myQuery->have_posts() ) : $myQuery->the_post();
- $postID = get_the_ID();
- $postDate = get_the_date('', $post->ID);
- $postTerms = wp_get_post_terms($postID, 'city', array("fields" => "all"));
- $postCity = $postTerms[0]->slug;
- $postCityName = $postTerms[0]->name;
- $cityLinkConstruct = $blogurl . '/cities/' . $postCity;
- $postCityLink = '<a href="' . $cityLinkConstruct . '">' . $postCityName . '</a>';
- $postStateTerms = wp_get_post_terms($postID, 'state', array("fields" => "all"));
- $postState = $postStateTerms[0]->slug;
- $postStateName = $postStateTerms[0]->name;
- $stateLinkConstruct = $blogurl . '/states/' . $postState;
- $postStateLink = '<a href="' . $stateLinkConstruct . '">' . $postStateName . '</a>';
- echo '<ul class="ckicon">';
- echo '<hr>';
- echo '<li itemprop="itemListElement">';
- echo '<span itemprop="url"><a href="' . get_post_permalink($postID) .'" rel="bookmark" title="' . get_the_title($postID) . '">' . get_the_title($postID) .'</a></span><br>';
- echo '<span class="entry-meta">Dateline: <span itemprop="datePublished"> ' . $postDate . '</span> <span class="middot-large">·</span> ' . $postCityLink . ', ' . $postStateLink . '</span>';
- //echo '<hr>';
- echo ( wpautop (the_excerpt()) );
- echo '</li>';
- echo '</ul>';
- endwhile;
- if ( $count <> 0 ) {
- echo '<p class="postlist-entry-meta">View all Stories in <a href="' . $term_link .'">' . $term->name . '</a>. <a href="' . $blogurl . '/add-your-story/">Share your <b>' . $term->name . '</b> story</a>!'; }
- wp_reset_postdata();
- }
- echo '</div><!-- end itemscope -->';
- }
- genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement