function be_portfolio($atts) { extract(shortcode_atts(array('col' => 'three', 'show_filters' => 'yes', 'filter' => 'categories', 'category' => '', 'style' => 'show_title', 'overlay_color' => '#000000', 'pagination' => 'yes', 'items_per_page' => '12'), $atts)); $output = ''; $output .= '<div class="portfolio ' . $col . '-col">'; $filter_to_use = 'portfolio_' . $filter; $category = explode(',', $category); if ($filter_to_use == 'tag' || empty($category)) { $terms = get_terms($filter_to_use); } else { $args_cat = array('taxonomy' => array($filter_to_use)); $stack = array(); foreach (get_categories($args_cat) as $single_category) { if (in_array($single_category->slug, $category)) { array_push($stack, $single_category->cat_ID); } } $terms = get_terms($filter_to_use, array('include' => $stack)); } if (!empty($terms) && $show_filters == 'yes') { $output .= '<div class="filters clearfix">'; $output .= '<span class="sort current_choice" data-id="element">All</span>'; foreach ($terms as $term) { $output .= '<span class="sort" data-id="' . $term->slug . '">' . $term->name . '</span>'; } $output .= '</div>'; //end filters } $output .= '<div class="portfolio-container clickable clearfix">'; global $paged; if ($paged == 0) { $offset = 0; } else { $offset = $items_per_page * $paged - $items_per_page; } if (empty($items_per_page)) { $items_per_page = -1; } if (empty($category[0])) { $args = array('post_type' => 'portfolio', 'posts_per_page' => $items_per_page, 'offset' => $offset, 'orderby' => 'menu_order', 'order' => 'ASC'); } else { $args = array('post_type' => 'portfolio', 'posts_per_page' => $items_per_page, 'tax_query' => array(array('taxonomy' => 'portfolio_categories', 'field' => 'slug', 'terms' => $category, 'operator' => 'IN')), 'offset' => $offset, 'orderby' => 'menu_order', 'order' => 'ASC'); } $the_query = new WP_Query($args); while ($the_query->have_posts()) { $the_query->the_post(); $filter_classes = ''; $post_terms = get_the_terms(get_the_ID(), $filter_to_use); if ($show_filters == 'yes' && is_array($post_terms)) { foreach ($post_terms as $term) { $filter_classes .= $term->slug . " "; } } else { $filter_classes = ''; } $attachment_id = get_post_thumbnail_id(get_the_ID()); if ($col == 'fullscreen') { $attachment_thumb = wp_get_attachment_image_src($attachment_id, 'portfolio-two'); } else { $attachment_thumb = wp_get_attachment_image_src($attachment_id, 'portfolio-' . $col); } $attachment_full = wp_get_attachment_image_src($attachment_id, 'full'); $attachment_thumb_url = $attachment_thumb[0]; $attachment_full_url = $attachment_full[0]; $video_url = get_post_meta($attachment_id, 'be_themes_featured_video_url', true); $visit_site_url = get_post_meta(get_the_ID(), 'be_themes_portfolio_visitsite_url', true); $link_to = get_post_meta(get_the_ID(), 'be_themes_portfolio_link_to', true); $thumb_options = get_post_meta(get_the_ID(), 'be_themes_thumbnail_lightbox', true); $permalink = ''; if (isset($link_to) && $link_to != 'no_link') { if ($link_to == 'external_url') { $permalink = $visit_site_url; } else { $permalink = get_permalink(); } } $mfp_class = 'mfp-image'; if (!empty($video_url)) { $attachment_full_url = $video_url; $mfp_class = 'mfp-iframe'; } if (isset($thumb_options) && $thumb_options == 'gallery') { $thumb_class = 'be-lightbox'; } else { $thumb_class = 'image-popup-vertical-fit'; } if ($col == 'one') { $output .= '<div class="element clearfix ' . $filter_classes . '">'; $output .= '<div class="be-row clearfix">'; $output .= '<div class="one-half column-block be-hoverlay"><div class="element-inner"><div class="thumb-wrap"><img src="' . $attachment_thumb_url . '" alt />'; $output .= '<div class="thumb-overlay"><div class="thumb-bg">'; $output .= '<div class="thumb-icons">'; if (!empty($permalink)) { $output .= '<a href="' . $permalink . '"><i class="font-icon icon-link"></i></a>'; } $output .= '<a href="' . $attachment_full_url . '" class="' . $thumb_class . ' ' . $mfp_class . '"><i class="font-icon icon-search"></i></a>'; if (isset($thumb_options) && $thumb_options == 'gallery') { $output .= '<div class="popup-gallery">'; $attachment_args = array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => get_the_ID(), 'orderby' => 'menu_order', 'order' => 'ASC'); $attachments = get_posts($attachment_args); foreach ($attachments as $att) { $video_url = get_post_meta($att->ID, 'be_themes_featured_video_url', true); $mfp_class = 'mfp-image'; if (!empty($video_url)) { $url = $video_url; $mfp_class = 'mfp-iframe'; } else { $url = wp_get_attachment_image_src($att->ID, 'full'); $url = $url[0]; } $output .= '<a href="' . $url . '" class="' . $mfp_class . '"></a>'; } $output .= '</div>'; } $output .= '</div>'; // end thumb icons $output .= '</div></div>'; //end thumb overlay & bg $output .= '</div>'; //end thumb wrap $output .= '</div>'; // end element-inner $output .= '</div>'; // one-half $output .= '<div class="one-half column-block">'; $output .= '<div class="portfolio-content-wrap">'; $output .= '<h3 class="portfolio-title"><a href="' . $permalink . '">' . get_the_title() . '</a></h3>'; $output .= '<ul class="secondary_text portfolio-categories clearfix">'; if (is_array($post_terms)) { foreach ($post_terms as $term) { $output .= '<li>' . $term->name . '</li>'; } } $output .= '</ul>'; $output .= '<div class="portfolio-content">' . get_the_excerpt() . '</div>'; $output .= do_shortcode('[button button_text= "Learn More" type= "small" gradient= "1" rounded= "1" icon= "" color= "#00bfd7" hover= "#00bfd7" url="' . get_permalink(get_the_ID()) . '" ]'); if (!empty($visit_site_url)) { $output .= do_shortcode('[button button_text= "Visit Site" type= "small" gradient= "1" rounded= "1" icon= "" color= "#00bfd7" hover= "#00bfd7" url="' . get_permalink(get_the_ID()) . '" ]'); } $output .= '</div>'; $output .= '</div>'; // end one half $output .= '</div>'; //end row $output .= do_shortcode('[separator style= "style-1" ]'); $output .= '</div>'; //end element } else { $output .= '<div class="element be-hoverlay ' . $filter_classes . '">'; $output .= '<div class="element-inner">'; switch ($style) { case 'no_title': $output .= '<div class="thumb-wrap"><img src="' . $attachment_thumb_url . '" alt />'; $output .= '<div class="thumb-overlay"><div class="thumb-bg">'; $output .= '<div class="thumb-icons">'; if (!empty($permalink)) { $output .= '<a href="' . $permalink . '"><i class="font-icon icon-link"></i></a>'; } $output .= '<a href="' . $attachment_full_url . '" class="' . $thumb_class . ' ' . $mfp_class . '"><i class="font-icon icon-search"></i></a>'; if (isset($thumb_options) && $thumb_options == 'gallery') { $output .= '<div class="popup-gallery">'; $attachment_args = array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => get_the_ID(), 'orderby' => 'menu_order', 'order' => 'ASC'); $attachments = get_posts($attachment_args); foreach ($attachments as $att) { $video_url = get_post_meta($att->ID, 'be_themes_featured_video_url', true); $mfp_class = 'mfp-image'; if (!empty($video_url)) { $url = $video_url; $mfp_class = 'mfp-iframe'; } else { $url = wp_get_attachment_image_src($att->ID, 'full'); $url = $url[0]; } $output .= '<a href="' . $url . '" class="' . $mfp_class . '"></a>'; } $output .= '</div>'; } $output .= '</div>'; // end thumb icons $output .= '</div></div>'; //end thumb overlay & bg $output .= '</div>'; //end thumb wrap break; case 'show_title': $output .= '<div class="thumb-wrap"><img src="' . $attachment_thumb_url . '" alt />'; $output .= '<div class="thumb-overlay"><div class="thumb-bg">'; $output .= '<div class="thumb-icons">'; if (!empty($permalink)) { $output .= '<a href="' . $permalink . '"><i class="font-icon icon-link"></i></a>'; } $output .= '<a href="' . $attachment_full_url . '" class="' . $thumb_class . ' ' . $mfp_class . '"><i class="font-icon icon-search"></i></a>'; if (isset($thumb_options) && $thumb_options == 'gallery') { $output .= '<div class="popup-gallery">'; $attachment_args = array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => get_the_ID(), 'orderby' => 'menu_order', 'order' => 'ASC'); $attachments = get_posts($attachment_args); foreach ($attachments as $att) { $video_url = get_post_meta($att->ID, 'be_themes_featured_video_url', true); $mfp_class = 'mfp-image'; if (!empty($video_url)) { $url = $video_url; $mfp_class = 'mfp-iframe'; } else { $url = wp_get_attachment_image_src($att->ID, 'full'); $url = $url[0]; } $output .= '<a href="' . $url . '" class="' . $mfp_class . '"></a>'; } $output .= '</div>'; } $output .= '</div>'; // end thumb icons $output .= '</div></div>'; //end thumb overlay & bg $output .= '</div>'; //end thumb wrap $output .= '<div class="sec-bg portfolio-title"><h5 class="sec-title-color">'; if (empty($permalink)) { $permalink = '#'; } $output .= '<a href="' . $permalink . '">' . get_the_title() . '</a>'; $output .= '</h5></div>'; break; case 'overlay_title': $rgb_color = be_themes_hexa_to_rgb($overlay_color); $output .= '<div class="thumb-wrap"><img src="' . $attachment_thumb_url . '" alt />'; $output .= '<div class="thumb-overlay" style="background:' . $overlay_color . ';background-color:rgba(' . $rgb_color[0] . ',' . $rgb_color[1] . ',' . $rgb_color[2] . ',0.8);"><div class="thumb-bg act-table">'; $output .= '<div class="overlay-thumb-title-wrap"><div class="overlay-thumb-title"><h5>'; if (empty($permalink)) { $permalink = '#'; } $output .= '<a href="' . $permalink . '">' . get_the_title() . '</a>'; $output .= '</h5><hr />'; $output .= '<span class="overlay-cats">'; $cat = array(); if (is_array($post_terms)) { foreach ($post_terms as $term) { array_push($cat, $term->name); } } $output .= implode(', ', $cat) . '</span></div></div>'; $output .= '<div class="overlay-thumb-icons">'; if (!empty($permalink) && $link_to != 'no_link') { $output .= '<a href="' . $permalink . '"><i class="font-icon icon-link"></i></a>'; } $output .= '<a href="' . $attachment_full_url . '" class="' . $thumb_class . ' ' . $mfp_class . '"><i class="font-icon icon-search"></i></a>'; if (isset($thumb_options) && $thumb_options == 'gallery') { $output .= '<div class="popup-gallery">'; $attachment_args = array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => get_the_ID(), 'orderby' => 'menu_order', 'order' => 'ASC'); $attachments = get_posts($attachment_args); foreach ($attachments as $att) { $video_url = get_post_meta($att->ID, 'be_themes_featured_video_url', true); $mfp_class = 'mfp-image'; if (!empty($video_url)) { $url = $video_url; $mfp_class = 'mfp-iframe'; } else { $url = wp_get_attachment_image_src($att->ID, 'full'); $url = $url[0]; } $output .= '<a href="' . $url . '" class="' . $mfp_class . '"></a>'; } $output .= '</div>'; } $output .= '</div>'; // end thumb icons $output .= '</div></div>'; //end thumb overlay & bg $output .= '</div>'; //end thumb wrap //end thumb wrap default: # code... break; } $output .= '</div>'; //end element inner $output .= '</div>'; //end element } } wp_reset_postdata(); $output .= '</div>'; //end portfolio-container if ($pagination == 'yes') { $output .= '<div class="pagination_parent">' . get_be_themes_pagination($the_query->max_num_pages) . '</div>'; //End Pagination } $output .= '</div>'; //end portfolio return $output; }
-sidebar-page"> <div id="content-wrap" class="be-wrap clearfix"> <section id="page-content" class="content-single-sidebar"> <div class="clearfix"> <?php $blog_style = $be_themes_data['blog_style']; if (empty($blog_style)) { $blog_style = '1'; } if (have_posts()) { while (have_posts()) { the_post(); get_template_part('loop'); } echo '<div class="pagination_parent">' . get_be_themes_pagination() . '</div>'; } else { echo '<p class="inner-content">' . __('Apologies, but no results were found. Perhaps searching will help find a related post.', 'be-themes') . '</p>'; } ?> </div> <!-- End Page Content --> </section> <section id="<?php echo $sidebar; ?> -sidebar"> <?php get_sidebar($sidebar); ?> </section>
function be_blog($atts) { global $be_themes_data; extract(shortcode_atts(array('col' => 'three', 'gutter_style' => 'style1', 'gutter_width' => 40), $atts)); $output = ''; global $paged, $blog_attr; $col = !isset($col) || empty($col) ? 'three' : $col; $blog_attr['gutter_style'] = !isset($gutter_style) || empty($gutter_style) ? 'style1' : $gutter_style; $blog_attr['gutter_width'] = !isset($gutter_width) || empty($gutter_width) ? intval(40) : intval($gutter_width); $blog_attr['style'] = 'shortcodes'; if ($blog_attr['gutter_style'] == 'style2') { $portfolio_wrap_style = 'style="margin-left: -' . $blog_attr['gutter_width'] . 'px;"'; } else { $portfolio_wrap_style = 'style="margin-right: ' . $blog_attr['gutter_width'] . 'px;"'; } $output .= '<div class="portfolio-all-wrap">'; $output .= '<div class="portfolio full-screen full-screen-gutter ' . $gutter_style . '-gutter ' . $col . '-col" data-gutter-width="' . $blog_attr['gutter_width'] . '" ' . $portfolio_wrap_style . ' data-col="' . $col . '">'; $output .= '<div class="style3-blog portfolio-container clickable clearfix">'; $blog_attr['gutter_width'] = $gutter_width; $args = array('post_type' => 'post', 'paged' => $paged); $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); ob_start(); get_template_part('blog/loop', 'shortcodes'); $output .= ob_get_contents(); ob_end_clean(); } } else { $output .= '<p class="inner-content">' . __('Apologies, but no results were found. Perhaps searching will help find a related post.', 'be-themes') . '</p>'; } $output .= '</div>'; //end portfolio-container $output .= $the_query->max_num_pages > 1 ? '<div class="pagination_parent" style="margin-left: ' . $blog_attr['gutter_width'] . 'px">' . get_be_themes_pagination($the_query->max_num_pages) . '</div>' : ''; $output .= '</div>'; $output .= '</div>'; //end portfolio wp_reset_postdata(); return $output; }
function get_blog_pagination($blog_attr, $portfolio_pagination_style) { global $wp_query; $items_per_page = get_option('posts_per_page'); if ($blog_attr['style'] == 'style3' && $blog_attr['pagination_style'] == 'infinite' && $wp_query->found_posts - $items_per_page > 0 && !(is_category() || is_archive() || is_tag() || is_search())) { echo '<div class="trigger_infinite_scroll blog_infinite_scroll" data-total-items="' . ($wp_query->found_posts - $items_per_page) . '"></div>'; } elseif ($blog_attr['style'] == 'style3' && $blog_attr['pagination_style'] == 'loadmore' && $wp_query->found_posts - $items_per_page > 0 && !(is_category() || is_archive() || is_tag() || is_search())) { echo '<div class="trigger_load_more blog_load_more" data-total-items="' . ($wp_query->found_posts - $items_per_page) . '" ' . $portfolio_pagination_style . '><a class="mediumbtn be-button rounded" href="#">' . __('Load More', 'be-themes') . '</a></div>'; } else { echo '<div class="pagination_parent" ' . $portfolio_pagination_style . '>' . get_be_themes_pagination() . '</div>'; } }