?> <!-- MAIN LOOP --> <?php while (have_posts()) { the_post(); ?> <?php $post_format = get_post_format(); $cmb_excerpt = get_post_meta(get_the_ID(), 'cmb_excerpt', true); $cmb_byline = get_post_meta(get_the_ID(), 'cmb_byline', true); $cmb_feature = get_post_meta(get_the_ID(), 'cmb_feature', true); $cmb_media_link = get_post_meta(get_the_ID(), 'cmb_media_link', true); $cmb_quote_is_tweet = get_post_meta(get_the_ID(), 'cmb_quote_is_tweet', true); $has_feature = mb_has_feature(get_the_ID()); ?> <?php //STANDARD POST + VIDEO POST + AUDIO POST + NO FEAT IMG POST if ($post_format === false || $post_format === "video" || $post_format === "audio") { ?> <div id="post-<?php the_ID(); ?> " <?php post_class("clearfix"); ?> > <!-- featured image -->
function timeline_load_more() { if (!wp_verify_nonce($_REQUEST['nonce'], 'timeline_load_more')) { exit('NONCE INCORRECT!'); } /************************************** GET VARS ***************************************/ //get options first $inspire_options = get_option('inspire_options'); $inspire_options_hp = get_option('inspire_options_hp'); //build vars $timeline_offset = $_REQUEST['offset']; $cmb_timeline_posts_per_page = $_REQUEST['posts_per_page']; $cmb_timeline_cat = $_REQUEST['category']; $cmb_timeline_order = $_REQUEST['order']; $exclude_string = $_REQUEST['exclude_string']; $default_excerpt_length = $_REQUEST['default_excerpt_length']; $cmb_timeline_link_through = $_REQUEST['link_through']; $cmb_timeline_display_content = $_REQUEST['display_content']; //calculate new offset $timeline_offset = $timeline_offset + $cmb_timeline_posts_per_page; /************************************** DATABASE QUERY ***************************************/ //basic args $query_args = array(); $query_args = array_merge($query_args, array('post_type' => 'post', 'post_status' => array('publish', 'future'), 'suppress_filters' => true, 'numberposts' => $cmb_timeline_posts_per_page + 1, 'offset' => $timeline_offset, 'category_name' => $cmb_timeline_cat, 'orderby' => 'post_date', 'order' => $cmb_timeline_order, 'exclude' => $exclude_string)); //final query $results_query = get_posts($query_args); /************************************** OUTPUT ***************************************/ //check if this is an ajax call and if so output if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { //copy/paste from page-timeline.php for ($i = 0; $i < count($results_query); $i++) { $this_post = $results_query[$i]; $post_format = get_post_format($this_post->ID); $cmb_excerpt = get_post_meta($this_post->ID, 'cmb_excerpt', true); $cmb_feature = get_post_meta($this_post->ID, 'cmb_feature', true); $cmb_media_link = get_post_meta($this_post->ID, 'cmb_media_link', true); $cmb_quote_is_tweet = get_post_meta($this_post->ID, 'cmb_quote_is_tweet', true); $cmb_byline = get_post_meta($this_post->ID, 'cmb_byline', true); $has_feature = mb_has_feature($this_post->ID); //STANDARD POST + VIDEO POST + AUDIO POST + NO FEAT IMG POST if ($post_format === false || $post_format === "video" || $post_format === "audio") { ?> <li id="milestone-<?php echo $timeline_offset + $i; ?> " class="milestone"> <!-- featured image --> <?php if ($cmb_feature == "media" && !empty($cmb_media_link)) { echo $cmb_media_link; } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($this_post->ID))) { echo '<div class="mosaic-block fade">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full'); $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true); printf('<a href="%s" class="mosaic-overlay fancybox-media fancybox.iframe play"></a>', esc_url($cmb_media_link)); printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt)); echo '</div>'; } elseif (has_post_thumbnail($this_post->ID) && get_post(get_post_thumbnail_id($this_post->ID))) { echo '<div class="mosaic-block fade">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full'); $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true); $img_post = get_post(get_post_thumbnail_id($this_post->ID)); printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title)); printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt)); echo '</div>'; } ?> <div class="milestone-container"> <!-- datetime --> <h6 class="time-date"><?php echo mb_localize_datetime(get_the_time(get_option('date_format'), $this_post->ID)); ?> </h6> <!-- title --> <?php if ($cmb_timeline_link_through == "checked") { printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($this_post->ID)), esc_attr($this_post->post_title)); } else { printf('<h3>%s</h3>', esc_attr($this_post->post_title)); } ?> <!-- excerpt/content --> <?php if ($cmb_timeline_display_content == "checked") { echo do_shortcode($this_post->post_content); } else { if (empty($cmb_excerpt)) { echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true); } else { echo do_shortcode($cmb_excerpt); } } if ($cmb_timeline_link_through == "checked") { printf('…<a class="more" href="%s">%s</a>', esc_url(get_permalink($this_post->ID)), __("more", "loc_canon")); } ?> </div> </li> <?php } //END STANDARD POST + VIDEO POST + AUDIO POST + NO FEAT IMG POST //QUOTE POST if ($post_format == "quote") { ?> <li id="milestone-<?php echo $timeline_offset + $i; ?> " class="milestone"> <div class="milestone-container"> <!-- datetime --> <h6 class="time-date"><?php echo mb_localize_datetime(get_the_time(get_option('date_format'), $this_post->ID)); ?> </h6> <!-- title --> <?php if ($cmb_timeline_link_through == "checked") { printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($this_post->ID)), esc_attr($this_post->post_title)); } else { printf('<h3>%s</h3>', esc_attr($this_post->post_title)); } ?> <!-- excerpt/content --> <?php if ($cmb_timeline_display_content == "checked") { if (!empty($this_post->post_content)) { echo do_shortcode($this_post->post_content); } } else { ?> <blockquote> <!-- excerpt --> <?php if (empty($cmb_excerpt)) { echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true); } else { echo do_shortcode($cmb_excerpt); } ?> <?php if (!empty($cmb_byline)) { printf('<cite>- %s</cite>', esc_attr($cmb_byline)); } ?> </blockquote> <?php } if ($cmb_timeline_link_through == "checked") { printf('<a class="more" href="%s">%s</a>', esc_url(get_permalink($this_post->ID)), __("more", "loc_canon")); } ?> </div> </li> <?php } //END QUOTE POST //GALLERY POST if ($post_format == "gallery") { // HANDLE POST SLIDER $consolidated_slider_array = array(); $cmb_post_slider_source = get_post_meta($this_post->ID, 'cmb_post_slider_source', true); $post_slider_array = mb_strip_wp_galleries_to_array($cmb_post_slider_source); $consolidated_slider_array = mb_convert_wp_galleries_array_to_consolidated_wp_gallery_array($post_slider_array); $gallery_class_array = array('fourth', 'fourth last-fold', 'fourth', 'fourth last'); $times_to_repeat = 4; ?> <li id="milestone-<?php echo $timeline_offset + $i; ?> " class="milestone"> <div class="milestone-container"> <!-- datetime --> <h6 class="time-date"><?php echo mb_localize_datetime(get_the_time(get_option('date_format'), $this_post->ID)); ?> </h6> <!-- title --> <?php if ($cmb_timeline_link_through == "checked") { printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($this_post->ID)), esc_attr($this_post->post_title)); } else { printf('<h3>%s</h3>', esc_attr($this_post->post_title)); } ?> <div class="clearfix gallery"> <?php if (empty($consolidated_slider_array)) { if ($has_feature) { // same as standard feature if ($cmb_feature == "media" && !empty($cmb_media_link)) { echo $cmb_media_link; } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($this_post->ID))) { echo '<div class="mosaic-block fade">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full'); $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true); printf('<a href="%s" class="mosaic-overlay fancybox-media fancybox.iframe play"></a>', esc_url($cmb_media_link)); printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt)); echo '</div>'; } elseif (has_post_thumbnail($this_post->ID) && get_post(get_post_thumbnail_id($this_post->ID))) { echo '<div class="mosaic-block fade">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full'); $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true); $img_post = get_post(get_post_thumbnail_id($this_post->ID)); printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title)); printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src[0]), esc_attr($img_alt)); echo '</div>'; } } } else { for ($n = 0; $n < $times_to_repeat; $n++) { if (isset($consolidated_slider_array[$n])) { $post_thumbnail_src = wp_get_attachment_image_src($consolidated_slider_array[$n]['id'], 'timeline_gallery_thumb_x2'); $img_alt = get_post_meta($consolidated_slider_array[$n]['id'], '_wp_attachment_image_alt', true); $img_post = get_post($consolidated_slider_array[$n]['id']); printf('<span class="%s"><img src="%s" alt="%s" /></span>', esc_attr($gallery_class_array[$n]), esc_url($post_thumbnail_src[0]), esc_attr($img_alt)); } } } ?> </div> <!-- excerpt/content --> <?php if ($cmb_timeline_display_content == "checked") { echo do_shortcode($this_post->post_content); } else { if (empty($cmb_excerpt)) { echo mb_make_excerpt($this_post->post_content, $default_excerpt_length, true); } else { echo do_shortcode($cmb_excerpt); } } if ($cmb_timeline_link_through == "checked") { printf('…<a class="more" href="%s">%s</a>', esc_url(get_permalink($this_post->ID)), __("more", "loc_canon")); } ?> </div> </li> <?php } } //copy/paste end } die; }
<ul class="timeline" data-offset="<?php echo $timeline_offset; ?> "> <?php for ($i = 0; $i < count($results_query); $i++) { $this_post = $results_query[$i]; $post_format = get_post_format($this_post->ID); $cmb_excerpt = get_post_meta($this_post->ID, 'cmb_excerpt', true); $cmb_feature = get_post_meta($this_post->ID, 'cmb_feature', true); $cmb_media_link = get_post_meta($this_post->ID, 'cmb_media_link', true); $cmb_quote_is_tweet = get_post_meta($this_post->ID, 'cmb_quote_is_tweet', true); $cmb_byline = get_post_meta($this_post->ID, 'cmb_byline', true); $has_feature = mb_has_feature($this_post->ID); //STANDARD POST + VIDEO POST + AUDIO POST + NO FEAT IMG POST (REMEMBER: CHANGES MUST ALSO BE MADE TO AJAX FUNCTION) if ($post_format === false || $post_format === "video" || $post_format === "audio") { ?> <li id="milestone-<?php echo $timeline_offset + $i; ?> " class="milestone"> <!-- featured image --> <?php if ($cmb_feature == "media" && !empty($cmb_media_link)) { echo $cmb_media_link; } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($this_post->ID))) { echo '<div class="mosaic-block fade">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_post->ID), 'full'); $img_alt = get_post_meta(get_post_thumbnail_id($this_post->ID), '_wp_attachment_image_alt', true);