defaults = array( 'link' => '', 'thumb' => 'portfolio-thumb', 'full' => 'portfolio-large', 'title' => 'above', 'title_link' => 'false', 'display' => '', 'heading' => 'Display', 'orderby' => 'date', 'order' => 'desc', 'posts_per_page' => -1, 'terms_orderby' => 'name', 'terms_order' => 'ASC', 'terms' => '', 'operator' => 'IN' ); } /** * Returns a filterable array of class defaults. * * @since 1.4.0 * @return array $defaults */ function defaults() { return apply_filters( 'arconix_portfolio_query_defaults', $this->defaults ); } /** * Return Porfolio Content * * Grab all portfolio items from the database and sets up their display. Accepts an array of arguments (see $defaults) * * Supported Arguments * - link => image | page | external - External is only supported at the item level * - thumb => any built-in image size * - full => any built-in image size (this setting is ignored of 'link' is set to 'page') * - title => above | below - Display the item title above or below the image * - title_link => true | false - Wrap the portfolio title in the same hyperlink as the image * - display => content | excerpt - Output the full content or an excerpt only. Leave blank for nothing * - heading => When displaying the 'feature' items in a row above the portfolio items, define the heading text for that section. * - orderby => date | any other orderby param available. {@see http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters} * - order => ASC | DESC * - posts_per_page => Limit how many portfolio items are returned (-1 is all) * - terms_orderby => Name or any other orderby param available. {@see http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters} * - terms_order => ASC | DESC * - terms => A 'feature' tag you want to filter on * - operator => IN | NOT IN - Include or exclude the value defined in the 'terms' param * * 'Image' is the only officially supported link option at the shortcode level. While linking to a page is possible, it may require additional coding * knowledge due to the fact that there are so many themes and nearly every one is different. External is not supported as a shortcode parameter. * {@see http://arconixpc.com/2012/linking-portfolio-items-to-pages } * * @since 1.2.0 * @version 1.4.0 * @param array $args Incoming arguments * @param bool $echo Echo or return the data * @return string Unordered list of portfolio items all dressed up with images and hyperlinks */ function loop( $args, $echo = false ) { // Merge incoming args with the function defaults $args = wp_parse_args( $args, $this->defaults() ); if( $args['title'] != "below" ) $args['title'] == "above"; // For backwards compatibility with "yes" and built-in data check // Default Query arguments $qargs = array( 'post_type' => 'portfolio', 'meta_key' => '_thumbnail_id', // Pull only items with featured images 'posts_per_page' => $args['posts_per_page'], 'orderby' => $args['orderby'], 'order' => $args['order'], ); // If the user has defined any tax terms, then we create our tax_query and merge to our main query if( $args['terms'] ) { $tax_qargs = array( 'tax_query' => array( array( 'taxonomy' => 'feature', 'field' => 'slug', 'terms' => $args['terms'], 'operator' => $args['operator'] ) ) ); // Merge the tax array with the general query $qargs = array_merge( $qargs, $tax_qargs ); } $s = ''; // our return container // Run our Query $query = new WP_Query( apply_filters( 'arconix_portfolio_query', $qargs ) ); if( $query->have_posts() ) : $s .= $this->before_items( $args ); while( $query->have_posts() ) : $query->the_post(); $s .= $this->item( $args ); endwhile; $s .= $this->after_items( $args ); endif; wp_reset_postdata(); // Either echo or return the results if( $echo === true ) echo $s; else return $s; } /** * Runs if there are portfolio items to loop through but before the items are output. * * Outputs the features list (if the 'feature' taxonomy is used) and the opening