function wpex_post_slider() { // Get gallery image ids $imgs = wpex_get_gallery_ids(); $lightbox_enabled = wpex_gallery_is_lightbox_enabled(); // Post vars global $post; $post_id = $post->ID; // No attachments, so do nothing if (!$imgs) { return; } ?> <div id="post-slider-wrap-<?php echo $post_id; ?> " class="post-slider-wrap clr flexslider-container"> <div id="post-slider-<?php echo $post_id; ?> " class="post-slider flexslider"> <ul class="slides clr"> <?php // Loop through each attachment ID foreach ($imgs as $img) { // Get image alt tag $img_url = wp_get_attachment_url($img); $cropped_img_url = wpex_get_featured_img_url($img); $img_alt = strip_tags(get_post_meta($img, '_wp_attachment_image_alt', true)); ?> <li> <?php // Display image with lightbox if ($lightbox_enabled == 'on') { ?> <a href="<?php echo $img_url; ?> " title="<?php echo $img_alt; ?> " rel="wpexLightboxGallery[]" class="wpex-lightbox-gallery"> <img src="<?php echo $cropped_img_url; ?> " alt="<?php echo $img_alt; ?> " /> </a> <?php } else { // Lightbox is disabled, only show image ?> <img src="<?php echo $cropped_img_url; ?> " alt="<?php echo $img_alt; ?> " /> <?php } ?> </li> <?php } ?> </ul><!-- .slides --> </div><!-- #post-slider .flexslider --> </div><!-- #post-slider-wrap --> <?php }
function wpex_related_posts() { // Return if disabled if (get_theme_mod('blog_related', '1') !== '1') { return; } // Get Post Data global $post; $post_id = $post->ID; // Return if not standard post type if (get_post_type($post) !== 'post') { return; } // Theme Settings $disable_related_items = get_post_meta($post_id, 'wpex_disable_related_items', true); $posts_per_page = get_theme_mod('blog_related_count', '3'); // Create an array of current category ID's $cats = wp_get_post_terms($post_id, 'category'); $cats_ids = array(); foreach ($cats as $wpex_related_cat) { $cats_ids[] = $wpex_related_cat->term_id; } // Related query arguments $args = array('posts_per_page' => $posts_per_page, 'orderby' => 'rand', 'category__in' => $cats_ids, 'post__not_in' => array($post_id), 'no_found_rows' => true, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote', 'post-format-link'), 'operator' => 'NOT IN'))); $wpex_query = new wp_query($args); if ($wpex_query->have_posts()) { ?> <section class="related-posts clr"> <div class="related-posts-title heading"><span><?php _e('Related Posts', 'wpex'); ?> </span></div> <?php // Loop through related posts $count = 0; foreach ($wpex_query->posts as $post) { setup_postdata($post); $count++; $postid = $post->ID; $attachment_id = get_post_thumbnail_id($postid); ?> <article class="related-post-entry span_1_of_3 col clr col-<?php echo $count; ?> "> <?php // Display related post thumbnail if (has_post_thumbnail()) { ?> <a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " rel="bookmark" class="related-post-entry-thumbnail"> <img src="<?php echo wpex_get_featured_img_url($attachment_id, false, false); ?> " alt="<?php echo the_title(); ?> " /> <?php if ('video' == get_post_format()) { ?> <div class="related-post-entry-video-overlay"><i class="fa fa-play-circle-o"></i></div> <?php } ?> </a> <?php } ?> <div class="related-post-entry-content clr"> <a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " rel="bookmark" class="related-post-entry-title"><?php the_title(); ?> </a> <div class="related-post-entry-excerpt clr"> <?php wpex_excerpt('15', false); ?> </div><!-- related-post-entry-excerpt --> </div><!-- .related-post-entry-content --> </article><!-- .related-post-entry --> <?php } ?> </section> <?php } // End related items // Reset query wp_reset_postdata(); }
</h1> </header><!-- #page-header --> <?php } ?> <div id="content" class="site-content left-content" role="main"> <?php while (have_posts()) { the_post(); ?> <?php if (has_post_thumbnail()) { ?> <div class="page-thumbnail"> <img src="<?php echo wpex_get_featured_img_url(); ?> " alt="<?php echo esc_attr(the_title_attribute('echo=0')); ?> " /> </div><!-- .page-thumbnail --> <?php } ?> <article id="post-<?php the_ID(); ?> " <?php post_class(); ?>
function wpex_homepage_slider() { global $post; if (!is_front_page()) { return; } // Get slides $wpex_query = new WP_Query(array('post_type' => 'slides', 'posts_per_page' => '-1', 'no_found_rows' => true)); // Display Slides if ($wpex_query->posts) { ?> <div id="homepage-slider-wrap" class="clr flexslider-container"> <div id="homepage-slider" class="flexslider"> <ul class="slides clr"> <?php // Loop through each slide foreach ($wpex_query->posts as $post) { setup_postdata($post); $post_id = $post->ID; $title = esc_attr(the_title_attribute('echo=0')); $caption = get_post_meta($post_id, 'wpex_slide_caption', true); $url = get_post_meta($post_id, 'wpex_slide_url', true); $url_target = get_post_meta($post_id, 'wpex_slide_target', true); $url_target = $url_target ? $url_target : 'blank'; ?> <li class="homepage-slider-slide"> <?php if ('' !== $url) { ?> <a href="<?php echo $url; ?> " title="<?php echo $title; ?> " target="_<?php echo $url_target; ?> "> <?php } ?> <div class="homepage-slide-inner container"> <div class="homepage-slide-content"> <div class="homepage-slide-title"><?php the_title(); ?> </div> <?php if ('' != $caption) { ?> <div class="clr"></div> <div class="homepage-slide-caption"><?php echo $caption; ?> </div> <?php } ?> </div><!-- .homepage-slider-content --> </div> <img src="<?php echo wpex_get_featured_img_url(); ?> " alt="<?php echo $title; ?> "> <?php if ('' !== $url) { ?> </a> <?php } ?> </li> <?php } ?> </ul><!-- .slides --> </div><!-- .flexslider --> </div><!-- #homepage-slider" --> <?php } // Reset post data wp_reset_postdata(); }