?> </div> <?php /* Start the Loop */ ?> <div class="wanderlist-widget wanderlist-country-overview-widget"> <h3 class="widget-title"><?php esc_html_e('Places I’ve Visited', 'wanderlist'); ?> </h3> <dl> <?php while (have_posts()) { the_post(); echo wanderlist_format_location(get_the_ID(), array('date_format' => 'range')); } ?> </dl> </div> <?php the_posts_navigation(); ?> </div> </article> <?php } else { get_template_part('content', 'none'); }
?> </div> <?php /* Start the Loop */ ?> <div class="wanderlist-widget wanderlist-trip-overview-widget"> <h3 class="widget-title"><?php esc_html_e('Where I went', 'wanderlist'); ?> </h3> <dl> <?php while (have_posts()) { the_post(); echo wanderlist_format_location(get_the_ID()); } ?> </dl> </div> <?php the_posts_navigation(); ?> </div> </article> <?php } else { ?> <?php
/** * Show a list of locations. * * This will default to showing all upcoming locations. * Passing the limit and show params will change its output. */ function wanderlist_list_locations($limit = null, $show = 'default') { $options = get_option('wanderlist_settings'); if ('all' === $show) { $order = 'DESC'; } elseif ('past' === $show) { $order = 'DESC'; $compare = '<='; } elseif ('upcoming' === $show) { $order = 'ASC'; $compare = '>'; } elseif ('default' === $show) { $order = 'ASC'; $compare = '>'; $limit = $limit - 1; } $args = array('post_type' => 'wanderlist-location', 'post_status' => array('future', 'publish'), 'posts_per_page' => $limit, 'orderby' => 'meta_value post_date', 'meta_key' => 'wanderlist-arrival-date', 'meta_value' => wanderlist_today(), 'meta_compare' => $compare, 'order' => $order, 'tax_query' => array(array('taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => $options['wanderlist_home_tag'], 'operator' => 'NOT IN'))); $location_query = new WP_Query($args); $locations = '<dl>'; // If we're not passing an upcoming/past parameter, show today's location if ('default' === $show) { $locations .= wanderlist_get_current_location('coords'); } // Generate a list of posts while ($location_query->have_posts()) { $location_query->the_post(); $locations .= wanderlist_format_location(get_the_ID()); wp_reset_postdata(); } $locations .= '</dl>'; return $locations; }