/** General selection **/ function tst_print_post_card($cpost) { if ($cpost->post_type == 'post') { $tax = tst_has_authors() ? 'auctor' : 'category'; tst_post_card($cpost, $tax); } else { $callback = "tst_" . $cpost->post_type . "_card"; if (is_callable($callback)) { call_user_func($callback, $cpost); } else { tst_post_card($cpost); } } }
function tst_cards_from_posts($atts) { extract(shortcode_atts(array('ids' => '', 'css' => '', 'pic_size' => 'full', 'link_text' => 'Веб-сайт'), $atts)); /** @var $ids */ /** @var $css */ /** @var $pic_size */ /** @var $link_text */ $posts = get_posts(array('post__in' => array_map('trim', explode(',', $ids)), 'post_type' => 'any', 'orderby' => array('menu_order' => 'DESC'))); ob_start(); ?> <section class="embed-cards-gallery" <?php echo $css; ?> > <div class="mdl-grid"> <?php foreach ($posts as $item) { $callback = "tst_" . get_post_type($item) . "_card"; if (is_callable($callback)) { call_user_func($callback, $item); } else { tst_post_card($item); } } ?> </div> </section> <?php $out = ob_get_contents(); ob_end_clean(); return $out; }
$title = get_post_meta($post_id, 'embed_posts_title', true); if (!empty($title)) { ?> <div class="mdl-cell mdl-cell--12-col"><h5><?php echo $title; ?> </h5></div> <?php } foreach ($embeds as $ep) { $ep = intval($ep); $callback = "tst_" . get_post_type($ep) . "_card"; if (is_callable($callback)) { call_user_func($callback, $ep); } else { tst_post_card($ep); } } } else { ?> <div class="mdl-cell mdl-cell--5-col mdl-cell--6-col-tablet"> <?php $r_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 3)); if ($r_query->have_posts()) { ?> <aside class="related-posts section"> <h5>Последние новости</h5> <?php foreach ($r_query->posts as $rp) { tst_compact_post_item($rp, true, 'category');