Пример #1
0
function cc_list_posts($atts, $content = null)
{
    global $cap, $post, $cc_js;
    $cc_page_options = cc_get_page_meta();
    $tmp = '';
    extract(shortcode_atts(array('amount' => '12', 'is_home_last_posts' => false, 'category__in' => array(), 'category_name' => '0', 'img_position' => 'mouse_over', 'height' => 'auto', 'page_id' => '', 'post_type' => 'post', 'orderby' => '', 'order' => '', 'year' => '', 'tag' => '', 'monthnum' => '', 'author' => ''), $atts));
    switch ($img_position) {
        case 'left':
            $img_position = 'posts-img-left-content-right';
            break;
        case 'right':
            $img_position = 'posts-img-right-content-left';
            break;
        case 'over':
            $img_position = 'posts-img-over-content';
            break;
        case 'under':
            $img_position = 'posts-img-under-content';
            break;
        case 'mouse_over':
            $img_position = 'boxgrid';
            break;
    }
    if (!is_array($category__in)) {
        $category__in = explode(',', $category__in);
    }
    if ($page_id != '') {
        $page_id = explode(',', $page_id);
    }
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array('orderby' => $orderby, 'order' => $order, 'post_type' => $post_type, 'post__in' => $page_id, 'year' => $year, 'monthnum' => $monthnum, 'category__in' => $category__in, 'category_name' => $category_name, 'posts_per_page' => $amount, 'tag' => $tag, 'paged' => $paged, 'author' => $author);
    if (($cap->default_homepage_last_posts == 'show' || $cap->default_homepage_last_posts == __('show', 'cc')) && !$is_home_last_posts) {
        $args['offset'] = 3;
    }
    remove_all_filters('posts_orderby');
    query_posts($args);
    if (have_posts()) {
        $thePath = array();
        $pattern = "/(?<=src=['|\"])[^'|\"]*?(?=['|\"])/i";
        archive_post_order($query_string);
        while (have_posts()) {
            the_post();
            // magazine style and on pages
            if ($cc_page_options['cc_page_template_on'] == 1 || $cap->posts_lists_style_taxonomy == 'magazine' || is_page_for_posts() && $cap->posts_lists_style_home == 'magazine' || $is_home_last_posts) {
                if ($img_position == 'boxgrid') {
                    $thumb = get_the_post_thumbnail($post->ID, 'post-thumbnail', __('List post image', 'cc'));
                    preg_match($pattern, $thumb, $thePath);
                    if (!isset($thePath[0])) {
                        $thePath[0] = get_template_directory_uri() . '/images/slideshow/noftrdimg-222x160.jpg';
                    }
                    $tmp .= '<div class="boxgrid captionfull" style="background: transparent url(' . $thePath[0] . ') repeat scroll 0 0; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; " title="' . get_the_title() . '">';
                    $tmp .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '"><img src="' . $thePath[0] . '" /></a>';
                    $tmp .= '<div class="cover boxcaption">';
                    $tmp .= '<h3><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h3>';
                    $tmp .= '<p class="hidden-phone"><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_excerpt() . '...</a></p>';
                    $tmp .= '</div>';
                    $tmp .= '</div>';
                } else {
                    $tmp .= '<div class="listposts ' . $img_position . '">';
                    if ($img_position != 'posts-img-under-content') {
                        $tmp .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, 'post-thumbnail', array('alt' => get_the_title())) . '</a>';
                    }
                    $tmp .= '<h3><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h3>';
                    if ($height != 'auto') {
                        $height = str_replace('px', '', $height) . 'px';
                    }
                    $tmp .= '<p style="height:' . $height . ';">' . get_the_excerpt() . '</p>';
                    if ($img_position == 'posts-img-under-content') {
                        $tmp .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, 'post-thumbnail', array('alt' => get_the_title())) . '</a>';
                    }
                    $tmp .= '</div>';
                    if ($img_position == 'posts-img-left-content-right' || $img_position == 'posts-img-right-content-left') {
                        $tmp .= '<div class="clear"></div>';
                    }
                }
                // blog
            } else {
                ?>
                <div id="post-<?php 
                the_ID();
                ?>
" <?php 
                post_class();
                ?>
>
                    <?php 
                if ($cap->posts_lists_hide_avatar == 'show' && !is_page_for_posts() || is_page_for_posts() && $cap->default_homepage_hide_avatar == 'show') {
                    ?>
                        <div class="author-box visible-desktop">
                            <?php 
                    echo get_avatar(get_the_author_meta('user_email'), '50');
                    ?>
                            <?php 
                    if (defined('BP_VERSION')) {
                        ?>
                                <p><?php 
                        printf(__('by %s', 'cc'), bp_core_get_userlink($post->post_author));
                        ?>
</p>
                            <?php 
                    }
                    ?>
                        </div>
                    <?php 
                }
                ?>

                    <div class="post-content span11">

                        <span class="marker visible-desktop"></span>

                        <h2 class="posttitle"><a href="<?php 
                the_permalink();
                ?>
" rel="bookmark" title="<?php 
                _e('Permanent Link to', 'cc');
                ?>
 <?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></h2>
                        <?php 
                if ($cap->posts_lists_hide_date == 'show' && !is_page_for_posts() || is_page_for_posts() && $cap->default_homepage_hide_date == 'show') {
                    ?>
                            <p class="date"><?php 
                    the_time('F j, Y');
                    ?>
 <em><?php 
                    _e('in', 'cc');
                    ?>
 <?php 
                    the_category(', ');
                    if (defined('BP_VERSION')) {
                        printf(__(' by %s', 'cc'), bp_core_get_userlink($post->post_author));
                    }
                    ?>
</em></p>
                        <?php 
                }
                ?>
                        <div class="entry">
                            <?php 
                do_action('blog_post_entry');
                ?>
                        </div>

                        <?php 
                $tags = get_the_tags();
                if ($tags) {
                    ?>
                            <p class="postmetadata"><span class="tags"><?php 
                    the_tags(__('Tags: ', 'cc'), ', ', '<br />');
                    ?>
</span> <span class="comments"><?php 
                    comments_popup_link(__('No Comments &#187;', 'cc'), __('1 Comment &#187;', 'cc'), __('% Comments &#187;', 'cc'));
                    ?>
</span></p>
                        <?php 
                } else {
                    ?>
                            <p class="postmetadata"><span class="comments"><?php 
                    comments_popup_link(__('No Comments &#187;', 'cc'), __('1 Comment &#187;', 'cc'), __('% Comments &#187;', 'cc'));
                    ?>
</span></p>
                        <?php 
                }
                ?>
                    </div>

                </div>
                <?php 
            }
        }
    }
    $tmp .= '<div class="clear"></div>';
    if ($img_position == 'boxgrid') {
        $cc_js['list_posts'] = true;
    }
    wp_reset_query();
    return '<div class="list-posts-all phone-hidden">' . $tmp . '</div>&nbsp;';
}
Пример #2
0
                <?php 
    if (have_posts()) {
        ?>

                    <div class="navigation">
                        <div class="alignleft"><?php 
        next_posts_link(__('&larr; Previous Entries', 'cc'));
        ?>
</div>
                        <div class="alignright"><?php 
        previous_posts_link(__('Next Entries &rarr;', 'cc'));
        ?>
</div>
                    </div>
                    <?php 
        archive_post_order($query_string);
        ?>
                    <?php 
        while (have_posts()) {
            the_post();
            ?>

                        <?php 
            do_action('bp_before_blog_post');
            ?>

                        <div id="post-<?php 
            the_ID();
            ?>
" <?php 
            post_class();