Black Friday & Cyber Monday Offer | Flat 20% OFF on Lifetime & All Themes Package. Use coupon code BFCM24 | Offer valid till 5th Dec 2024 Buy Now

WordPress Website Templates

Find Professional WordPress themes Easy and Simple to Setup

inner banner

category specific gallery

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7343
    Giancarlo
    Participant

    Hi,

    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

    #7353
    Grace Themes
    Member

    Hi 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 Themes

    #7359
    Giancarlo
    Participant

    hi,

    i prefer not to share my credentials.. sorry

    #7382
    Grace Themes
    Member

    Hi 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.