/** * Render related posts carousel * @param string $post_type The post type to determine correct related posts and headings * * @return string HTML markup to display related posts **/ function avada_render_related_posts($post_type = 'post') { $html = ''; // Set the needed variables according to post type if ($post_type == 'post') { $theme_option_name = 'related_posts'; $main_heading = __('Related Posts', 'Avada'); } elseif ($post_type == 'avada_portfolio') { $theme_option_name = 'portfolio_related_posts'; $main_heading = __('Related Projects', 'Avada'); } // Check if related posts should be shown if (fusion_get_option($theme_option_name, 'related_posts', get_the_ID()) == 'yes' || fusion_get_option($theme_option_name, 'related_posts', get_the_ID()) == '1') { if ($post_type == 'post') { $related_posts = fusion_get_related_posts(get_the_ID(), Avada()->settings->get('number_related_posts')); } elseif ($post_type == 'avada_portfolio') { $related_posts = fusion_get_related_projects(get_the_ID(), Avada()->settings->get('number_related_posts')); } // If there are related posts, display them if ($related_posts->have_posts()) { $html .= '<div class="related-posts single-related-posts">'; ob_start(); echo do_shortcode(sprintf('[title size="3" content_align="left" style_type="default"]%s[/title]', $main_heading)); $html .= ob_get_clean(); // Get the correct image size if ('cropped' == Avada()->settings->get('related_posts_image_size')) { $featured_image_size = 'fixed'; $data_image_size = 'fixed'; } else { $featured_image_size = 'full'; $data_image_size = 'auto'; } // Set the meta content variable if ('title_on_rollover' == Avada()->settings->get('related_posts_layout')) { $data_meta_content = 'no'; } else { $data_meta_content = 'yes'; } // Set the autoplay variable if (Avada()->settings->get('related_posts_autoplay')) { $data_autoplay = 'yes'; } else { $data_autoplay = 'no'; } // Set the touch scroll variable if (Avada()->settings->get('related_posts_swipe')) { $data_swipe = 'yes'; } else { $data_swipe = 'no'; } $carousel_item_css = ''; if (sizeof($related_posts->posts) < Avada()->settings->get('related_posts_columns')) { $carousel_item_css = ' style="max-width: 300px;"'; } $html .= sprintf('<div class="fusion-carousel" data-imagesize="%s" data-metacontent="%s" data-autoplay="%s" data-touchscroll="%s" data-columns="%s" data-itemmargin="%s" data-itemwidth="180" data-touchscroll="yes" data-scrollitems="%s">', $data_image_size, $data_meta_content, $data_autoplay, $data_swipe, Avada()->settings->get('related_posts_columns'), Avada()->settings->get('related_posts_column_spacing'), Avada()->settings->get('related_posts_swipe_items')); $html .= '<div class="fusion-carousel-positioner">'; $html .= '<ul class="fusion-carousel-holder">'; // Loop through related posts while ($related_posts->have_posts()) { $related_posts->the_post(); $html .= sprintf('<li class="fusion-carousel-item"%s>', $carousel_item_css); $html .= '<div class="fusion-carousel-item-wrapper">'; // Title on rollover layout if ('title_on_rollover' == Avada()->settings->get('related_posts_layout')) { $html .= avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, FALSE, FALSE, 'disable', 'default', 'related'); // Title below image layout } else { $html .= avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, FALSE, FALSE, 'disable', 'disable', 'related'); // Get the post title $html .= sprintf('<h4 class="fusion-carousel-title"><a href="%s"%s>%s</a></h4>', get_permalink(get_the_ID()), '_self', get_the_title()); $html .= '<div class="fusion-carousel-meta">'; $html .= sprintf('<span class="fusion-date">%s</span>', get_the_time(Avada()->settings->get('date_format'), get_the_ID())); $html .= '<span class="fusion-inline-sep">|</span>'; $comments = $comments_link = ''; ob_start(); comments_popup_link(__('0 Comments', 'Avada'), __('1 Comment', 'Avada'), '% ' . __('Comments', 'Avada')); $comments_link = ob_get_clean(); $html .= sprintf('<span>%s</span>', $comments_link); $html .= '</div>'; // fusion-carousel-meta } $html .= '</div>'; // fusion-carousel-item-wrapper $html .= '</li>'; } $html .= '</ul>'; // fusion-carousel-holder // Add navigation if needed if (Avada()->settings->get('related_posts_navigation')) { $html .= '<div class="fusion-carousel-nav"><span class="fusion-nav-prev"></span><span class="fusion-nav-next"></span></div>'; } $html .= '</div>'; // fusion-carousel-positioner $html .= '</div>'; // fusion-carousel $html .= '</div>'; // related-posts wp_reset_postdata(); } } return $html; }
echo __('Share This Story, Choose Your Platform!', 'Avada'); ?> </h4> <?php echo $social_icons->render_social_icons($sharingbox_social_icon_options); ?> </div> <?php } ?> <?php if ($smof_data['portfolio_related_posts'] && get_post_meta($post->ID, 'pyre_related_posts', true) != 'no' || !$smof_data['portfolio_related_posts'] && get_post_meta($post->ID, 'pyre_related_posts', true) == 'yes') { ?> <?php $projects = fusion_get_related_projects($post->ID, $smof_data['number_related_posts']); ?> <?php if ($projects->have_posts()) { ?> <div class="related-posts related-projects"> <div class="fusion-title title"><h2 class="title-heading-left"><?php echo __('Related Projects', 'Avada'); ?> </h2><div class="title-sep-container"><div class="title-sep sep-double"></div></div></div> <div id="carousel" class="es-carousel-wrapper fusion-carousel-large"> <div class="es-carousel"> <ul> <?php while ($projects->have_posts()) { $projects->the_post();