• Hello,
    I’ve got a function that is called in a custom post type that displays a portfolio. I’ve got all the porfolios being queried on my ‘Our Work’ page. I would like to add comments to those porfolios and i’ve been able to get the comment form to show on the page but I want it to show inside of a div layer inside of the porfolio. No matter what i’ve tried the comment for is displaying outside of the porfolio. Any ideas?
    Cheers,
    Mike

    Here’s my code.

    function portfolio($atts,$content){
    		extract(shortcode_atts(array(
            'col'=>'four',
    		'pagination' => '',
    		'showposts' => -1,
    		'category' => ''),$atts));
    		global $touch_slider_viewport_height;
    		global $touch_slider_item_width;
    		global $touch_slider_two_col_aspect_ratio;
    		$output="";
    		if($col == "two" || $col =="three"){
    			$touch_slider_viewport_height = get_touch_slider_item_height($touch_slider_item_width,$touch_slider_two_col_aspect_ratio);
    		}
    		$select_cat=$category;
    		$category_array=explode(",",$category);
    		$args_cat = array( 'taxonomy' => array( 'portfolio-set') );
    		$stack = array();
    		foreach(get_categories($args_cat) as $single_category){
    			if (in_array($single_category->slug, $category_array)) {
    				$category_ids=$single_category->cat_ID;
    				array_push($stack, $single_category->cat_ID);
    			}
    		}
    		$terms = get_terms('portfolio-set', array(
    							'include'    => $stack,
    						)
    					);
    		$output.='<div class="portfolio_all_container">';
    		if($terms && (count($terms) > 1)){
    			$output.='<div class="categorys_list">';
    			$categorys="";
                $lastElement = end($terms);
                $output.='<span class="sort current_choice" data-id="element">All / </span>';
                foreach ($terms as $term) {
                    $output.='<span class="sort" data-id="'.$term->slug.'">'.$term->name.'</span>';
                    if($term != $lastElement) {
                        $output.=' / ';
                    }
                }
    			$output.='</div>';
    		}
    
    		$output.='<div class="portfolio '.$col.'-col">';
    		$output.='<div class="'.$pagination.' portfolio-container portfolio clickable clearfix">';
    
    		global $paged;
    
    		$offset = ( ( $showposts * $paged ) - $showposts );
    		if($paged == 0) {
    			$offset=0;
    		}
    		else {
    			$offset = ( ( $showposts * $paged ) - $showposts );
    		}
    		if($category) {
    			if($pagination) {
    				$args = array(
    					'post_type' => 'portfolio',
    					'posts_per_page' => $showposts,
    					'offset' => $offset,
    					'tax_query' => array(
    						array(
    							'taxonomy' => 'portfolio-set',
    							'field' => 'slug',
    							'terms' => explode(",",$category),
    							'operator' => 'IN'
    						)
    					)
    				);
    			}
    			else {
    				$args = array(
    					'post_type' => 'portfolio',
    					'showposts' => -1,
    					'tax_query' => array(
    						array(
    							'taxonomy' => 'portfolio-set',
    							'field' => 'slug',
    							'terms' => explode(",",$category),
    							'operator' => 'IN'
    						)
    					)
    				);
    			}
    		}
    		else {
    			if($pagination) {
    				$args = array(
    					'post_type' => 'portfolio',
    					'posts_per_page' => $showposts,
    					'offset' => $offset
    				);
    			}
    			else {
    				$args = array(
    					'post_type' => 'portfolio',
    					'posts_per_page' => $showposts
    				);
    			}
    		}
    		$the_query = new WP_Query( $args );
    		while ( $the_query->have_posts() ) : $the_query->the_post();
    			$terms=wp_get_object_terms( get_the_ID(), 'portfolio-set' );
    			$category="";
    			$portfolio_url="";
    			$portfolio_url=get_post_meta(get_the_ID(), 'portfolio_url',true);
    			$portfolio_time="";
    			$portfolio_time=get_post_meta(get_the_ID(), 'portfolio_time',true);
    			$taxonomies=get_the_term_list( get_the_ID(), 'portfolio-set', '', ' / ', '' );
    
    			foreach ($terms as $term) {
    				$category.=$term->slug." ";
    			}
    					$output.='<div class="element '.$category.'">
    								<div class="single_element">
    									<div class="thumbnill">';
    										$attachment_id = get_post_thumbnail_id(get_the_ID());
    										$attachment_info=wp_get_attachment_image_src( $attachment_id, 'gallery_image');
    										$attachment_url = $attachment_info[0];
    										$output.='<input type="hidden" class="post_id" value="'.get_the_ID() .'" />';
    										$output.='<input type="hidden" class="column" value="'.$col.'" />';
    											$output.='<div class="thumbnil_image"><img src="'.$attachment_url.'" /><div class="gallery_thumbnil_overlay"></div><div class="thumbnil_image_drop"></div></div>
    											<div class="thumbnill_title">'.get_the_title().'</div><div class="title-cat">'.$taxonomies.'</div>
    											<div class="title-m">'.get_the_date('M').'</div><div class="title-d">'.get_the_date('j').'</div></div>
    										<div class="touchslider" style="display: none;">
    										<div class="slider_header">
    											<ul class="slider_head clearfix">
    												<li class="left slider_title">'.get_the_title().'</li><div class="swap-comments">'.comments_template( '/comment.php', false ).'</div>
    											</ul>
    										</div>';
    										$is_video_selected = get_post_meta(get_the_ID(), 'portfolio_video_select',true);
    										if(isset($is_video_selected) && $is_video_selected =='on') {
    											$output.='<div class="video_folio"><div class="video_content"></div><div class="close_slider_video"></div></div>';
    										}
    										else {
    											$output.='<div class="close_slider"></div>';
    										}
    										$output.='<div class="description">
    										<ul class="slider_foot clearfix">
    											<li class="left description_content">';
    												if(get_the_content()) {
    													$output.='<div>'.do_shortcode(get_the_content()).'</div>';
    													}
    											$output.='</li>';
    											$output.='<li class="left description_more">';
    											$output.='<ul class="slider_footer_link">';
    											$output.='<li>';
    											if(!empty($portfolio_url)) {
    												$output.='<a class="visite_site" href="'.$portfolio_url.'">'.__('Visit Site','swap').'</a>';
    											}
    											$output.='</li>';
    											$output.='<li>';
    											if(!empty($portfolio_time)) {
    												$output.='<span class="time">'.$portfolio_time.'</span>';
    											}
    											$output.='</li>';
    											$output.='</ul>';
    											$output.='</li>';
    										$output.='</ul>';
    						$output.='</div>';
    					$output.='</div>';
    				$output.='</div>';
    			$output.='</div>';
    		endwhile;
    		wp_reset_postdata();
    		$output.='</div>';
    		if($pagination) {
    			if($pagination == 'standard') {
    				$output.='<div class="pagination_parent">';
    				$output.= get_swap_pagination($the_query->max_num_pages);
    				$output.='</div>';
    			}
    			else {
    				$output.='<div class="trigger_infinite_scroll" paged="2" count="'.$showposts.'" cat="'.$select_cat.'"></div><div class="portfolio_infinite_scroll_loader"><img src="'.get_bloginfo('template_url').'/img/preloader.gif" /></div>';
    			}
    		}
    		$output.='</div>';
    		$output.='<style>.touchslider-viewport,.touchslider-item { height: '.$touch_slider_viewport_height['desktop_four_column'].'px;}.touchslider-prev,.touchslider-next{top: '.($touch_slider_viewport_height['desktop_four_column']/2).'px;} .three-col .touchslider-viewport,.three-col .touchslider-item, .two-col .touchslider-viewport,.two-col .touchslider-item{ height: '.$touch_slider_viewport_height["desktop_two_column"].'px; } .three-col .touchslider-prev,.three-col .touchslider-next, .two-col .touchslider-prev,.two-col .touchslider-next{top: '.($touch_slider_viewport_height['desktop_two_column']/2).'px;}@media only screen and (min-width: 768px) and (max-width: 959px) {.two-col .touchslider-viewport ,.touchslider-viewport, .touchslider-item { height: '.$touch_slider_viewport_height['tablet'].'px !important;} .touchslider-prev,.touchslider-next{top: '.($touch_slider_viewport_height['tablet']/2).'px !important;}} @media only screen and (max-width: 767px) { two-col .touchslider-viewport ,.touchslider-viewport,.touchslider-item { height: '.$touch_slider_viewport_height['mob_port'].'px !important;} .touchslider-prev,.touchslider-next{top: '.(($touch_slider_viewport_height['mob_port']/2)+50).'px !important;} } @media only screen and (min-width: 480px) and (max-width: 767px) { two-col .touchslider-viewport ,.touchslider-viewport,.touchslider-item { height: '.$touch_slider_viewport_height['mob_land'].'px !important;} .touchslider-prev,.touchslider-next{top: '.(($touch_slider_viewport_height['mob_land']/2)+50).'px !important;} } </style>';
    		$output.='</div>';
    		return $output;
    	}
    	add_shortcode('portfolio','portfolio');

  • The topic ‘Comments Inside a Custom Post Type Slider’ is closed to new replies.