bigspring / monolith

A starter theme for WordPress built with Twitter Bootstrap
MIT License
9 stars 1 forks source link

Refactor Pages shortcode #289

Closed simonpmiles closed 9 years ago

simonpmiles commented 9 years ago

Needs to be overwritten with this -

function pages_shortcode($atts, $content = null) {

    extract( shortcode_atts( array( // set our defaults for the shortcode
        'layout' => 'list', // default layout
        'ids' => '',
        'class' => '',
        'size' => '',
        'exclude_pages' => null,
        'image_border' => 'false',
        'image' => true,
        'title' => true,
        'excerpt' => true,
        'readmore' => true,
        'orderby' => 'menu_order',
        'order' => 'ASC'

    ), $atts ) );

    $page_ids = array();
    $page_ids = explode(',', $atts['ids']);

    // get the posts
    $args = array(
        'post__in' => $page_ids,
        'post_type' => 'page',
        'order' => 'ASC',
        'orderby' => 'menu_order'

    );

    // define our arguments for the builder based on whether we want to show images, titles, etc
    $builder_args = array();
    $builder_args['is_thumbnail'] = ($image_border == 'false') ? false : true;
    $builder_args['has_image'] = ($image == 'false') ? false : true;
    $builder_args['has_title'] = ($title == 'false') ? false : true;
    $builder_args['has_summary'] = ($excerpt == 'false') ? false : true;
    $builder_args['has_readmore'] = ($readmore == 'false') ? false : true;
        $builder_args['orderby'] = $orderby;
    $builder_args['classes'] = $class;
    $builder_args['size'] = $size;

    ob_start();
    build($layout, $builder_args, $args);
    return ob_get_clean();

}//end function
add_shortcode('pages', 'pages_shortcode');