// LOOP
$search = array('post_type' => 'masthead', 'tax_query' => array(array('taxonomy' => 'issue', 'field' => 'slug', 'terms' => current_taxonomy())));
$mastQuery = new WP_Query($search);
if ($mastQuery->have_posts()) {
    while ($mastQuery->have_posts()) {
        $mastQuery->the_post();
        $mast = '<li class="toc-item"><a class="toc-link webapp" href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
    }
}
?>
			<?php 
// LOOP
$args = array('post_type' => 'article', 'tax_query' => array(array('taxonomy' => 'issue', 'field' => 'slug', 'terms' => current_taxonomy())));
$query = new WP_Query($args);
if ($query->have_posts()) {
    echo '<h2>' . custom_taxonomies_terms_links() . '</h2>';
    echo '<ul class="toc-item-list">';
    if (isset($mast)) {
        echo $mast;
    }
    while ($query->have_posts()) {
        $query->the_post();
        $link = get_permalink();
        $rel = wp_make_link_relative($link);
        echo '<li class="toc-item">';
        echo '<a class="toc-link webapp" href="' . $rel . '">' . get_the_title() . '</a>';
        echo '</li>';
    }
    echo '</ul>';
}
?>
                    $uom = __('km', GEODIRECTORY_TEXTDOMAIN);
                }
                echo round($distance, 2) . ' ' . __($uom, GEODIRECTORY_TEXTDOMAIN) . '
			<br />
			';
            }
            ?>
                                </h3>
                            <?php 
        }
        ?>

                            <div class="card-category">

                            <?php 
        echo custom_taxonomies_terms_links();
        // $terms = get_the_terms( $post->ID , 'taxonomyname' );
        // foreach ( $terms as $term ) {
        // echo $term->name;
        // $post_details = geodir_get_post_info($post->ID);
        // $cat_ID = $post->default_category;
        // $post_type = $post->post_type;
        // echo $cat_ID;
        // echo $post_type;
        // echo get_term_by( $post->ID, $post_type);
        ?>

                            </div>

                        
                            <div class="entry-port-title">
                                <h6 id="post-<?php 
        the_ID();
        ?>
" <?php 
        post_class('port-title');
        ?>
><a href="<?php 
        the_permalink();
        ?>
"><?php 
        the_title();
        ?>
</a></h6>
                                <div class="ep-cat"><?php 
        echo substr(custom_taxonomies_terms_links(), 0, -2);
        ?>
</div>
                            </div>
 
                                                                    
                        </article>
                    
                    </li><!-- end of .pxd-4 -->

                
                <?php 
    }
}
?>
            
function sre2t_ajax()
{
    //Function used for generating results for display in PRE tag and saving as TXT
    // sets correct values for start and end date + adds WP "post_where" filter
    if (($_POST['sdate'] != 'all' || $_POST['edate'] != 'all') && !empty($_POST['sdate'])) {
        add_filter('posts_where', 'filter_where');
        function filter_where($where = '')
        {
            if ($_POST['sdate'] != 'all' && $_POST['edate'] == 'all') {
                $sdate = "AND post_date >= '" . $_POST['sdate'] . "'";
            } elseif ($_POST['edate'] != 'all' && $_POST['sdate'] == 'all') {
                $edate = "AND post_date < '" . $_POST['edate'] . "'";
            } else {
                $sdate = " AND post_date >= '" . $_POST['sdate'] . "'";
                $edate = " AND post_date < '" . $_POST['edate'] . "'";
            }
            $where .= $sdate;
            $where .= $edate;
            return $where;
        }
    }
    $args = array('posts_per_page' => -1, 'post_type' => $_POST['post_type'], 'post_status' => $_POST['post_status'], 'order' => ASC, 'meta_key' => $_POST['cfname'], 'meta_value' => $_POST['cfvalue']);
    //creates arrays for taxonomies
    $is_tax_query = 0;
    foreach ($_POST['taxonomy'] as $key => $value) {
        if (!in_array('e2t_all', $value)) {
            if ($is_tax_query == 0) {
                $args['tax_query'] = array('relation' => 'OR');
                $is_tax_query = 1;
            }
            $temp = array('taxonomy' => $key, 'field' => 'id', 'terms' => $value);
            array_push($args['tax_query'], $temp);
        }
    }
    //adds argument for authors
    if (!in_array('e2t_all', $_POST['author'])) {
        $args['author'] = implode(',', $_POST['author']);
    }
    $export_to_text = new WP_Query($args);
    // new custom loop to get desired results
    if ($export_to_text->have_posts()) {
        if (!is_array($_POST['data_filter'])) {
            $_POST['data_filter'] = array();
        }
        $labels = implode("\t", $_POST['data_filter']);
        echo $_POST['download'] == '0' ? '<strong>' . $labels . '</strong><br />' : $labels . "\r\n";
        // echoes labels differently for Pre and TXT file
        while ($export_to_text->have_posts()) {
            $export_to_text->the_post();
            $ett_post = '';
            if (in_array('ID', $_POST['data_filter'])) {
                $ett_post .= get_the_ID() . "\t";
            }
            if (in_array('Title', $_POST['data_filter'])) {
                $ett_post .= get_the_title() . "\t";
            }
            if (in_array('Date', $_POST['data_filter'])) {
                $ett_post .= get_the_date() . "\t";
            }
            if (in_array('Post Type', $_POST['data_filter'])) {
                $ett_post .= get_post_type() . "\t";
            }
            if (in_array('Categories', $_POST['data_filter'])) {
                foreach (get_the_category() as $category) {
                    $ett_post .= $category->cat_name . ',';
                }
                $ett_post .= "\t";
            }
            if (in_array('Tags', $_POST['data_filter'])) {
                if (has_tag()) {
                    foreach (get_the_tags() as $tag) {
                        $ett_post .= $tag->name . ',';
                    }
                } else {
                    $ett_post .= '';
                }
                $ett_post .= "\t";
            }
            if (in_array('Custom Taxonomies', $_POST['data_filter'])) {
                $ett_post .= custom_taxonomies_terms_links() . "\t";
            }
            if (in_array('Permlink', $_POST['data_filter'])) {
                $ett_post .= get_permalink() . "\t";
            }
            if (in_array('Content', $_POST['data_filter'])) {
                global $more;
                $more = 1;
                $thepostcontent = htmlentities(get_the_content(), ENT_QUOTES | ENT_IGNORE, "UTF-8");
                $thepostcontent = preg_replace('/[\\t\\r\\n]*/', '', $thepostcontent);
                $ett_post .= $thepostcontent . "\t";
            }
            if (in_array('Author', $_POST['data_filter'])) {
                $ett_post .= get_the_author() . "\t";
            }
            if (in_array('Author Email', $_POST['data_filter'])) {
                $ett_post .= get_the_author_email() . "\t";
            }
            if (in_array('Custom Fields', $_POST['data_filter'])) {
                $custom_field_keys = get_post_custom_keys();
                if (!empty($custom_field_keys)) {
                    foreach ($custom_field_keys as $key => $value) {
                        $valuet = trim($value);
                        if ('_' != $valuet[0]) {
                            $mykey_values = get_post_custom_values($value);
                            foreach ($mykey_values as $key2 => $value2) {
                                $ett_post .= htmlentities(preg_replace('/[\\t\\r\\n]*/', '', "{$value} => {$value2}. "), ENT_QUOTES | ENT_IGNORE, "UTF-8");
                            }
                        }
                    }
                } else {
                    $ett_post .= '';
                }
                $ett_post .= "\t";
            }
            if (in_array('Comments', $_POST['data_filter'])) {
                $args = array('status' => 'approve', 'post_id' => get_the_ID());
                $comments = get_comments($args);
                $first = 1;
                foreach ($comments as $comment) {
                    $comment_content = htmlentities($comment->comment_content, ENT_QUOTES | ENT_IGNORE, "UTF-8");
                    $comment_content = preg_replace('/[\\t\\r\\n]*/', '', $comment_content);
                    $ett_post .= $comment->comment_author . ' => ' . $comment_content . '. ';
                }
                $ett_post .= "\t";
            }
            echo $_POST['download'] == '0' ? $ett_post . '<br/>' : html_entity_decode($ett_post) . "\r\n";
            // echoes single result differently for Pre and TXT file
        }
    } else {
        echo 'No results';
    }
    if (($_POST['sdate'] != 'all' || $_POST['edate'] != 'all') && !empty($_POST['sdate'])) {
        remove_filter('posts_where', 'filter_where');
    }
    die;
    //Functions echoing for AJAX must die
}
function dimox_breadcrumbs()
{
    /* === OPTIONS === */
    $text['home'] = 'Home';
    // text for the 'Home' link
    $text['category'] = '%s';
    // text for a category page
    $text['search'] = 'Search Results for "%s" Query';
    // text for a search results page
    $text['tag'] = 'Posts Tagged "%s"';
    // text for a tag page
    $text['author'] = 'Articles Posted by %s';
    // text for an author page
    $text['404'] = 'Not Found';
    // text for the 404 page
    $showCurrent = 1;
    // 1 - show current post/page title in breadcrumbs, 0 - don't show
    $showOnHome = 0;
    // 1 - show breadcrumbs on the homepage, 0 - don't show
    $delimiter = ' > ';
    // delimiter between crumbs
    $before = '<span class="current">';
    // tag before the current crumb
    $after = '</span>';
    // tag after the current crumb
    /* === END OF OPTIONS === */
    global $post;
    $homeLink = home_url() . '/';
    $linkBefore = '<span typeof="v:Breadcrumb">';
    $linkAfter = '</span>';
    $linkAttr = ' rel="v:url" property="v:title"';
    $link = $linkBefore . '<a' . $linkAttr . ' href="%1$s">%2$s</a>' . $linkAfter;
    $q_object = get_queried_object();
    $taxonomy = $q_object->taxonomy;
    // $term = $q_object->get_queried_object();
    $name = $q_object->name;
    $slug = $q_object->slug;
    //$terms = get_terms($name);
    $terms = get_the_terms($post->ID, $taxonomy);
    $parent = get_term($term->parent, $taxonomy);
    $tax_link = get_terms($taxonomy);
    $yo = get_the_term_list($id, $taxonomy, $before, $delimiter, $after);
    //$post_link = get_post_type_archive_link( 'all-bikes' );
    //$parent = get_term( $id, $taxonomy);
    //$parent_slug = $parent->slug;
    //$parent = &get_term( $id, $taxonomy, OBJECT, 'raw');
    if (is_home() || is_front_page()) {
        if ($showOnHome == 1) {
            echo '<div id="crumbs"><a href="' . $homeLink . '">' . $text['home'] . '</a></div>';
        }
    } else {
        echo '<div id="crumbs" xmlns:v="http://rdf.data-vocabulary.org/#">' . sprintf($link, $homeLink, $text['home']) . $delimiter;
        if (is_category()) {
            echo $before;
            $thisCat = get_category(get_query_var('cat'), false);
            if ($thisCat->parent != 0) {
                $cats = get_category_parents($thisCat->parent, TRUE, $delimiter);
                $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
                $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
                echo $cats;
            }
            echo sprintf($text['category'], single_cat_title('', true)) . $after;
        } elseif (is_tax($taxonomy)) {
            $tax_link = get_term_link($name, $taxonomy);
            ?>
			<a href="<?php 
            echo site_url() . '/events';
            ?>
">Events</a>
			<?php 
            echo $delimiter;
            echo $before . $name . $after;
        } elseif (is_single()) {
            //echo $post->ID;
            $terms = get_the_terms($post->ID, 'events');
            function custom_taxonomies_terms_links()
            {
                global $post, $post_id;
                // get post by post id
                $post =& get_post($post->ID);
                // get post type by post
                $post_type = $post->post_type;
                // get post type taxonomies
                $taxonomies = get_object_taxonomies($post_type);
                foreach ($taxonomies as $taxonomy) {
                    // get the terms related to post
                    $terms = get_the_terms($post->ID, $taxonomy);
                    if (!empty($terms)) {
                        $out = array();
                        foreach ($terms as $term) {
                            $out[] = '<a href="' . get_term_link($term->slug, $taxonomy) . '">' . $term->name . '</a>';
                        }
                        $return = join(', ', $out);
                    }
                }
                return $return;
            }
            $custom_term = custom_taxonomies_terms_links();
            ?>
			
			
			<a href="<?php 
            echo site_url() . '/events';
            ?>
">Events</a>
			<?php 
            echo $delimiter . $custom_term;
            echo $before;
            the_title();
            echo $after;
        } elseif (is_search()) {
            echo $before . sprintf($text['search'], get_search_query()) . $after;
        } elseif (is_day()) {
            echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
            echo sprintf($link, get_month_link(get_the_time('Y'), get_the_time('m')), get_the_time('F')) . $delimiter;
            echo $before . get_the_time('d') . $after;
        } elseif (is_month()) {
            echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
            echo $before . get_the_time('F') . $after;
        } elseif (is_year()) {
            echo $before . get_the_time('Y') . $after;
        } elseif (is_single() && !is_attachment()) {
            if (get_post_type() != 'post') {
                $post_type = get_post_type_object(get_post_type());
                $slug = $post_type->rewrite;
                printf($link, $homeLink . '/' . $slug['slug'] . '/', $post_type->labels->singular_name);
                if ($showCurrent == 1) {
                    echo $delimiter . $before . get_the_title() . $after;
                }
            } else {
                $cat = get_the_category();
                $cat = $cat[0];
                $cats = get_category_parents($cat, TRUE, $delimiter);
                if ($showCurrent == 0) {
                    $cats = preg_replace("#^(.+){$delimiter}\$#", "\$1", $cats);
                }
                $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
                $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
                echo $cats;
                if ($showCurrent == 1) {
                    echo $before . get_the_title() . $after;
                }
            }
        } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
            $post_type = get_post_type_object(get_post_type());
            echo $before . $post_type->labels->singular_name . $after;
        } elseif (is_attachment()) {
            $parent = get_post($post->post_parent);
            $cat = get_the_category($parent->ID);
            $cat = $cat[0];
            $cats = get_category_parents($cat, TRUE, $delimiter);
            $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
            $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
            echo $cats;
            printf($link, get_permalink($parent), $parent->post_title);
            if ($showCurrent == 1) {
                echo $delimiter . $before . get_the_title() . $after;
            }
        } elseif (is_page() && !$post->post_parent) {
            if ($showCurrent == 1) {
                echo $before . get_the_title() . $after;
            }
        } elseif (is_page() && $post->post_parent) {
            $parent_id = $post->post_parent;
            $breadcrumbs = array();
            while ($parent_id) {
                $page = get_page($parent_id);
                $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID));
                $parent_id = $page->post_parent;
            }
            $breadcrumbs = array_reverse($breadcrumbs);
            for ($i = 0; $i < count($breadcrumbs); $i++) {
                echo $breadcrumbs[$i];
                if ($i != count($breadcrumbs) - 1) {
                    echo $delimiter;
                }
            }
            if ($showCurrent == 1) {
                echo $delimiter . $before . get_the_title() . $after;
            }
        } elseif (is_tag()) {
            echo $before . sprintf($text['tag'], single_tag_title('', false)) . $after;
        } elseif (is_author()) {
            global $author;
            $userdata = get_userdata($author);
            echo $before . sprintf($text['author'], $userdata->display_name) . $after;
        } elseif (is_404()) {
            echo $before . $text['404'] . $after;
        }
        if (get_query_var('paged')) {
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ' (';
            }
            echo __('Page', 'twentytwelve') . ' ' . get_query_var('paged');
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ')';
            }
        }
        echo '</div>';
    }
}