// now get the top sidebar, etc.
// Now, the posts
global $wp_query;
$old_query = $wp_query;
$args = array('ignore_sticky_posts' => false, 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged);
$filter = weaverx_get_per_page_value('_pp_post_filter');
// ATW Show Posts filter
if (function_exists('atw_showposts_installed') && $filter != '') {
    $params = atw_posts_get_filter_params($filter);
    if ($params != '') {
        // they specified a $filter arg, so use it and wipe out anything else...
        $fargs = shortcode_parse_atts($params);
    } else {
        $fargs = '';
    }
    $qargs = atw_posts_get_qargs($fargs, array());
    $wp_query = new WP_Query(apply_filters('weaverx_pwp_wp_query', $qargs));
    // reuse $wp_query to make paging work
} else {
    $args = weaverx_setup_post_args($args);
    // setup custom fields for this page
    $wp_query = new WP_Query(apply_filters('weaverx_pwp_wp_query', $args));
    // reuse $wp_query to make paging work
}
// now have to put the sidebar
get_template_part('templates/infobar');
// put the info bar now that the posts info is available
echo $top_of_pwp;
if (have_posts()) {
    // same loop as index.php
    global $weaverx_sticky;
function atw_show_posts_shortcode($args = '')
{
    /* implement [weaver_show_posts]  */
    /* DOC NOTES:
    CSS styling: The group of posts will be wrapped with a <div> with a class called
    .wvr-show-posts. You can add an additional class to that by providing a 'class=classname' option
    (without the leading '.' used in the actual CSS definition). You can also provide inline styling
    by providing a 'style=value' option where value is whatever styling you need, each terminated
    with a semi-colon (;).
    
    The optional header is in a <div> called .wvr_show_posts_header. You can add an additional class
    name with 'header_class=classname'. You can provide inline styling with 'header_style=value'.
    
    .wvr-show-posts .hentry {margin-top: 0px; margin-right: 0px; margin-bottom: 40px; margin-left: 0px;}
    .widget-area .wvr-show-posts .hentry {margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;}
    */
    $opts = array('cols' => '1', 'excerpt_length' => '', 'hide_bottom_info' => '', 'hide_featured_image' => '', 'hide_title' => '', 'hide_top_info' => '', 'show' => '', 'show_avatar' => false, 'more_msg' => '', 'use_paging' => false, 'no_top_clear' => false);
    $slider = '';
    $filter = '';
    if (isset($args['slider'])) {
        $slider = $args['slider'];
        unset($args['slider']);
        if (!function_exists('atw_slider_installed')) {
            return '<strong>ERROR with [show_posts slider="' . $slider . '"]: Weaver Slider Plugin not installed.</strong>';
        }
        if ($slider == '' || atw_posts_get_slider_opt('name', $slider) == '') {
            return '<strong>ERROR with [show_posts slider="' . $slider . '"]: You must specify a valid slider name.</strong>';
        }
        $filter = atw_posts_get_slider_opt('selected_slider_filter', $slider);
        if ($filter == '') {
            $filter = 'default';
        }
        if (atw_posts_get_filter_opt('slug', $filter) != $filter) {
            return '<strong>ERROR with [show_posts slider="' . $slider . '"]: Filter (' . $filter . ') is not a defined filter.</strong>';
        }
        $params = atw_posts_get_filter_params($filter);
        if ($params != '') {
            // they specified a $filter via slider, so wipe out everything else
            unset($args);
            $args = shortcode_parse_atts($params);
            $args['use_paging'] = false;
            // use_paging breaks sliders
        } else {
            $filter = '';
        }
    } else {
        if (isset($args['filter'])) {
            $filter = $args['filter'];
            $params = atw_posts_get_filter_params($filter);
            if ($params != '') {
                // they specified a $filter arg, so use it and wipe out anything else...
                unset($args);
                $args = shortcode_parse_atts($params);
            } else {
                $filter = '';
            }
        }
    }
    $qargs = atw_posts_get_qargs($args, $opts);
    extract(shortcode_atts($opts, $args));
    // setup local vars
    if ($show == 'titlelist' && $slider) {
        $show = 'title';
    }
    // cheap fix...
    // set transient opts for these options
    atw_trans_set('showposts', true);
    // global to see if we are in this function
    atw_trans_set('show', $show);
    // this will always be set - but '' (blank) implies 'full' for built-in, but not Weaver/Aspen settings for them
    if ($hide_title != '') {
        atw_trans_set('hide_title', true);
    }
    if ($hide_top_info != '') {
        atw_trans_set('hide_top_info', true);
    }
    if ($hide_bottom_info != '') {
        atw_trans_set('hide_bottom_info', true);
    }
    if ($hide_featured_image != '') {
        atw_trans_set('hide_featured_image', true);
    }
    if (isset($args['show_avatar'])) {
        // need this weirdness for Aspen/Weaver compatibility (not set means use global setting)
        if ($show_avatar) {
            atw_trans_set('show_avatar', true);
        } else {
            atw_trans_set('show_avatar', 'no');
        }
    }
    if ($more_msg != '') {
        atw_trans_set('more_msg', $more_msg);
    }
    $ourposts = new WP_Query(apply_filters('atw_show_posts_wp_query', $qargs, $args));
    /* now start the content */
    $class = '';
    if ($filter != '') {
        $class = ' atw-show-posts-filter-' . $filter;
    }
    $content = '';
    $tail = '';
    if ($slider == '') {
        $content = '';
        if (!$no_top_clear) {
            $content = '<div style="clear:both;"></div>';
        }
        $content .= '<div class="atw-show-posts' . $class . '">';
        $tail = "</div><!-- show_posts -->\n";
    }
    ob_start();
    if ($slider && function_exists('atw_slider_installed') && atw_posts_get_slider_opt('content_type', $slider) == 'images') {
        atw_slider_do_gallery($ourposts, $slider);
        // reset stuff
        wp_reset_query();
        wp_reset_postdata();
        atw_trans_clear_all();
        $content .= ob_get_clean();
        // get the output
        return $content;
    }
    $slide_li_begin = '';
    $slide_li_end = '';
    if ($slider) {
        $style = '';
        $slide_li_begin = '<div class="atwk-slide"><div class="slide-content slide-post"' . $style . '>' . "\n";
        $slide_li_end = "\n</div></div><!-- slide-content slide-post -->\n";
    }
    // add excerpt filter here
    if ($excerpt_length != '') {
        $GLOBALS['atw_show_posts_excerpt_length'] = $excerpt_length;
        add_filter('excerpt_length', 'atw_posts_excerpt_length_filter', 20);
        // user our excerpt filter early to override others
    }
    if ($show == 'titlelist') {
        echo '<ul>';
    }
    $posts_out = 0;
    $col = 0;
    if (!$ourposts->have_posts()) {
        echo __('No posts found.', 'atw_showposts');
    }
    if (WEAVER_SHOWPOSTS_TEMPLATE && atw_posts_get_filter_opt('post_template', $filter)) {
        require_once dirname(__FILE__) . '/atw-posts-template.php';
    }
    // NOW - load the template code
    while ($ourposts->have_posts()) {
        $ourposts->the_post();
        $posts_out++;
        echo $slide_li_begin;
        // aspen_per_post_style();
        if ($show == 'titlelist') {
            ?>
            <li><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            printf(esc_attr(__('Permalink to %s', 'show-posts')), the_title_attribute('echo=0'));
            ?>
" rel="bookmark"><?php 
            the_title();
            ?>
</a></li>
    <?php 
        } else {
            switch ($cols) {
                case 2:
                    $col++;
                    $style = '';
                    if ($col % 2 == 1) {
                        // force stuff to be even
                        $style = ' style="clear:left;"';
                    }
                    echo '<div class="atw-content-2-col atw-cf"' . $style . '>' . "\n";
                    atw_show_content($slider, $filter);
                    echo "</div> <!-- atw-content-2-col -->\n";
                    break;
                case 3:
                    $col++;
                    $style = '';
                    if ($col % 3 == 1) {
                        // force stuff to be even
                        $style = ' style="clear:left;"';
                    }
                    echo '<div class="atw-content-3-col atw-cf"' . $style . '>' . "\n";
                    atw_show_content($slider, $filter);
                    echo "</div> <!-- atw-content-3-col -->\n";
                    break;
                case 1:
                default:
                    atw_show_content($slider, $filter);
                    break;
            }
            // end switch $cols
        }
        echo $slide_li_end;
    }
    // end loop
    if ($show == 'titlelist') {
        echo "</ul>\n";
    }
    // unhook excerpt filter here
    if ($excerpt_length != '') {
        unset($GLOBALS['atw_show_posts_excerpt_length']);
        remove_filter('excerpt_length', 'atw_posts_excerpt_length_filter', 20);
        // user our excerpt filter early to override others
    }
    if ($use_paging) {
        if (!$no_top_clear) {
            echo '<div style="clear:both;"></div>';
        }
        ?>
    <div id="atw-show-posts-navigation" class="atw-post-nav">
<?php 
        $big = 999999;
        echo paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, $qargs['paged']), 'total' => $ourposts->max_num_pages));
        ?>
    </div>
<?php 
    }
    $content .= ob_get_clean();
    // get the output
    // get posts
    $content .= $tail;
    // reset stuff
    wp_reset_query();
    wp_reset_postdata();
    atw_trans_clear_all();
    return $content;
}