category specific gallery
- This topic has 3 replies, 2 voices, and was last updated 5 years, 11 months ago by
Grace Themes.
-
AuthorPosts
-
January 10, 2018 at 7:29 pm #7343
Giancarlo
ParticipantHi,
is possible for me show only images that are member of a specific category?
[photogallery filter=”true” show=”8″]
With this shortcode i am able only to hide or show filter bur all images are always displayed…
Thanks
January 11, 2018 at 5:50 am #7353Grace Themes
MemberHi Giancarlo,
To display photo gallery of specific category, it will need to changes some code.
Please send your website URL and WordPress admin login details for temporary at [email protected] so we can make changes in your website photo gallery.
Regards
Grace ThemesJanuary 11, 2018 at 5:22 pm #7359Giancarlo
Participanthi,
i prefer not to share my credentials.. sorry
January 14, 2018 at 6:06 am #7382Grace Themes
MemberHi Giancarlo,
To show photo gallery of specific category in your page
Go to Appearance -> Editor -> custom-functions.php
add below new code at the end of custom-functions.php file//[photogallery_cat] function photogallery_cat_shortcode_func( $atts ) { extract( shortcode_atts( array( 'show' => -1, 'category' => '', ), $atts ) ); $pfStr = ''; $pfStr .= '<div class="photobooth">'; $pfStr .= '<div class="row fourcol portfoliowrap"><div class="portfolio">'; $j=0; //query_posts('post_type=photogallery&posts_per_page='.$show); $args = array( 'post_type' => 'photogallery', 'posts_per_page' => $show, 'tax_query' => array( array( 'taxonomy' => 'gallerycategory', 'field' => 'ID', 'terms' => $category ), ) ); query_posts( $args ); if ( have_posts() ) : while ( have_posts() ) : the_post(); $j++; $videoUrl = get_post_meta( get_the_ID(), 'video_file_url', true); $imgSrc = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); $terms = wp_get_post_terms( get_the_ID(), 'gallerycategory', array("fields" => "all")); $slugAr = array(); foreach( $terms as $tv ){ $slugAr[] = $tv->term_id; } if ( $imgSrc[0]!='' ) { $imgUrl = $imgSrc[0]; }else{ $imgUrl = get_template_directory_uri().'/images/img_404.png'; } $pfStr .= '<div class="entry '.implode(' ', $slugAr).'"> <div class="holderwrap"> <a href="'.( ($videoUrl) ? $videoUrl : $imgSrc[0] ).'" data-rel="prettyPhoto[bkpGallery]"><img src="'.$imgSrc[0].'"/></a> <h5>'.get_the_title().'</h5> </div> </div>'; unset( $slugAr ); endwhile; else: $pfStr .= '<p>Sorry, photo gallery is empty.</p>'; endif; wp_reset_query(); $pfStr .= '</div></div>'; $pfStr .= '</div>'; return $pfStr; } add_shortcode( 'photogallery_cat', 'photogallery_cat_shortcode_func' );
Now use this short code to display images of specific category.
You need to change photo gallery category ID in (category=”3″)[photogallery_cat category="3" show="10"]
Please check and let me know your feedback.
Regards
Grace Themes -
AuthorPosts
- You must be logged in to reply to this topic.