function educator_posts_shortcode($atts, $content = null) { $atts = shortcode_atts(array('ids' => '', 'number' => 6, 'categories' => null), $atts); $params = array('post_type' => 'post', 'posts_per_page' => intval($atts['number'])); // Get posts by IDs. if ($atts['ids']) { $ids = explode(' ', $atts['ids']); $params['post__in'] = array(); foreach ($ids as $id) { if (is_numeric($id)) { $params['post__in'][] = $id; } } $params['posts_per_page'] = -1; $params['orderby'] = 'post__in'; $params['ignore_sticky_posts'] = true; } // Categories. if ($atts['categories']) { $categories = explode(' ', $atts['categories']); foreach ($categories as $key => $term_id) { $categories[$key] = intval($term_id); } $params['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => $categories)); } $query = new WP_Query($params); $output = ''; if ($query->have_posts()) { $output .= '<div class="posts-carousel owl-carousel">'; while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); $output .= '<article class="post-grid">'; if (has_post_thumbnail()) { $output .= '<div class="post-thumb"><a href="' . esc_url(get_permalink()) . '">' . get_the_post_thumbnail($post_id, 'ib-educator-grid') . '</a></div>'; } $output .= '<div class="post-body">'; $output .= '<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '">' . the_title('', '', false) . '</a></h2>'; ob_start(); the_excerpt(); $output .= '<div class="post-excerpt">' . ob_get_clean() . '</div>'; $output .= '</div>'; if (function_exists('educator_post_meta')) { $output .= '<footer class="post-meta">' . educator_post_meta(array('date', 'comments')) . educator_share('menu') . '</footer>'; } $output .= '</article>'; } wp_reset_postdata(); $output .= '</div>'; } return $output; }
the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); ?> <div class="post-excerpt entry-summary"> <?php if (post_password_required()) { _e('This post is password protected.', 'ib-educator'); } elseif (is_search()) { the_excerpt(); } else { $continue_reading = get_theme_mod('continue_reading') ? sprintf(__('Continue reading %s', 'ib-educator'), the_title('<span class="screen-reader-text">', '</span>', false)) : ''; the_content($continue_reading); } ?> </div> <?php if (is_sticky()) { echo '<div class="post-badge post-badge-sticky"></div>'; } ?> </div> <footer class="post-meta"> <?php echo educator_post_meta(array('date', 'comments')); echo educator_share('menu'); ?> </footer> </article>
?> <?php $show_thumbnail = get_post_meta(get_the_ID(), '_educator_show_image', true); ?> <?php if (1 == $show_thumbnail && has_post_thumbnail()) { ?> <div class="post-thumb"> <?php the_post_thumbnail('ib-educator-main-column'); ?> </div> <?php } ?> <div class="entry-content"> <?php the_content(); wp_link_pages(array('before' => '<div class="page-links"><span class="page-links-title">' . __('Pages:', 'ib-educator') . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>')); ?> </div> <footer class="post-meta"> <?php echo educator_post_meta(); ?> </footer> </article>