php - Wordpress portfolio page display only images from certain filter -
i have been following many tutorials on portfolio uses quicksand.js filter animation. in function can create filters (categories) slugs. can't, after endless hour of reading, figure out how display thumbnails filter.
i've included parts of portfolio functions.php
i know lot of code, last resort. can't working hoping php / wordpress guru might point out i've missed.
through reading on it, did managed pull out featured images posted in 'featured' using:
<?php $args = array( 'post_type' => 'portfolio', 'tax_query' => array( array( 'taxonomy' => 'filter', 'field' => 'slug', 'terms' => 'featured' ) ) ); $query = new wp_query( $args ); ?>
however, pulls out image , it's title, without formatted html need. applying use lost.
thanks in advance.
my index.php
h2>featured work</h2> <ul id="image_gallery" class="group index_gallery filterable-grid"> <?php // query out database $wpbp = new wp_query(array( 'post_type' => 'portfolio', 'posts_per_page' =>'9' ) ); ?> <?php $terms = get_terms("filter"); $count = count($terms); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms $term ) { echo "<li>" . $term->name . "</li>"; } echo "</ul>"; } ?> <?php // begin loop if ($wpbp->have_posts()) : while ($wpbp->have_posts()) : $wpbp->the_post(); ?> <?php // taxonomy 'filter' categories $terms = get_the_terms( get_the_id(), 'filter' ); ?> <?php $large_image = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_id()), 'fullsize', false, '' ); $large_image = $large_image[0]; ?> <?php //apply data-id unique indentity, //and loop through taxonomy , assign terms portfolio item data-type, // referenced when writing our quicksand script ?> <li class="gallery_image" data-id="id-<?php echo $count; ?>" data-type="<?php foreach ($terms $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>"> <?php // check if wordpress supports featured images, , if output thumbnail if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> <?php // output featured image ?> <a rel="prettyphoto[gallery]" class="zoom" href="<?php echo $large_image ?>"> <img class="mag" src="<?php bloginfo('template_url'); ?>/imgs/mag.png"/><div class="thumb_bg"></div><?php the_post_thumbnail('portfolio'); ?> </a> <?php endif; ?> <!--<?php // output title of each portfolio item ?> <p><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></p>--> </li> <?php $count++; // increase count 1 ?> <?php endwhile; endif; // end wordpress loop ?> <?php wp_reset_query(); // reset query loop?> </ul> <div class="gallery_control"> <a href="<?php echo home_url(); ?>/portfolio/" class="gallery-btn artwork"><span class="icon-search"></span>view more</a> </div> <?php $taxonomy = 'filter'; $terms = get_terms( $taxonomy, '' ); if ($terms) { foreach($terms $term) { echo '<p>' . '<a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf( __( "view posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> has ' . $term->count . ' post(s). </p> '; } } ?>
portfolio workings:
// function: post_type begin function post_type() { $labels = array( 'name' => __( 'portfolio'), 'singular_name' => __('portfolio'), 'rewrite' => array( 'slug' => __( 'portfolio' ) ), 'add_new' => _x('add item', 'portfolio'), 'edit_item' => __('edit portfolio item'), 'new_item' => __('new portfolio item'), 'view_item' => __('view portfolio'), 'search_items' => __('search portfolio'), 'not_found' => __('no portfolio items found'), 'not_found_in_trash' => __('no portfolio items found in trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array( 'title', 'editor', 'thumbnail' ) ); register_post_type(__( 'portfolio' ), $args); } // function: post_type end // function: portfolio_messages begin function portfolio_messages($messages) { $messages[__( 'portfolio' )] = array( 0 => '', 1 => sprintf(('portfolio updated. <a href="%s">view portfolio</a>'), esc_url(get_permalink($post_id))), 2 => __('custom field updated.'), 3 => __('custom field deleted.'), 4 => __('portfolio updated.'), 5 => isset($_get['revision']) ? sprintf( __('portfolio restored revision %s'), wp_post_revision_title((int)$_get['revision'], false)) : false, 6 => sprintf(__('portfolio published. <a href="%s">view portfolio</a>'), esc_url(get_permalink($post_id))), 7 => __('portfolio saved.'), 8 => sprintf(__('portfolio submitted. <a target="_blank" href="%s">preview portfolio</a>'), esc_url( add_query_arg('preview', 'true', get_permalink($post_id)))), 9 => sprintf(__('portfolio scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">preview portfolio</a>'), date_i18n( __( 'm j, y @ g:i' ), strtotime($post->post_date)), esc_url(get_permalink($post_id))), 10 => sprintf(__('portfolio draft updated. <a target="_blank" href="%s">preview portfolio</a>'), esc_url( add_query_arg('preview', 'true', get_permalink($post_id)))), ); return $messages; } // function: portfolio_messages end // function: portfolio_filter begin function portfolio_filter() { register_taxonomy( __( "filter" ), array(__( "portfolio" )), array( "hierarchical" => true, "label" => __( "filter" ), "singular_label" => __( "filter" ), "rewrite" => array( 'slug' => 'filter', 'hierarchical' => true ) ) ); } // function: portfolio_filter end add_action( 'init', 'post_type' ); add_action( 'init', 'portfolio_filter', 0 ); add_filter( 'post_updated_messages', 'portfolio_messages' );
i not sure doing here change this
<?php $large_image = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_id()), 'fullsize', false, '' ); $large_image = $large_image[0]; ?>
to this
<?php $large_images[] = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_id()), 'fullsize', false, '' ); $large_image = $large_images[0]; ?>
Comments
Post a Comment