badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Link gallery item til gallery custom post.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13367
    Peer
    Member

    Hello.

    Nice theme. I a portfolio alike function. Right now I have made a gallery, via the built-in custom post type “gallery”.
    When I view the gallery, the image and title of the gallery post shows, and that’s nice.

    Now, I would like to have the image and the title to link to the actual custom post. How can I achieve that? 🙂

    http://www.kompetenze.dk/konsulenter/ (gallery)
    http://www.kompetenze.dk/gallery/maria-andersen/ (gallery item I’d like to link the image+title to)

    BTW. where do I find the line to change the “gallery” slug? 🙂

    Thanks in advance

    #13393

    Hi Peer,

    I think you don’t want this popup right ? So you need code customisation for it but We recommended not to change the code because if you change the code then while updating to our new version all your customisation code will be lost. So better make child theme and first unhook the functions and the edit the code.

    http://codex.wordpress.org/Child_Themes

    How to change it ?

    => first goto theme folder (interface pro) -> inc -> content-extension.php on
    line number 1102 ==> for two column
    line number 1214 ==> for three column and
    line number 1326 ==> for four column

    I think that you have used three coulmn, copy this all function to your child theme. Create functions.php on your child theme first

    add_action( 'interface_gallery_three_column_template_content', 'interface_gallery_three_column_template_content', 10 );
    /**
     * Displays the three column gallery content
     */
    function interface_gallery_three_column_template_content() { ?>
    	<div id="content">
    		<ul class="gal-filter clearfix">
    			<li class="active no-padding-left"><a href="javascript:void(0)" class="all" title="ALL"><?php _e('All','interface');?></a></li>/
    			<?php
    					// Get the taxonomy
    					$terms = get_terms('gallery_category');
    					
    					// set a count to the amount of categories in our taxonomy
    					$count = count($terms); 
    					
    					// set a count value to 0
    					$i=0;
    					
    					// test if the count has any categories
    					if ($count > 0) {
    						
    						// break each of the categories into individual elements
    						$term_list ='';
    						foreach ($terms as $term) {
    							
    							// increase the count by 1
    							$i++;
    							
    							// rewrite the output for each category
    							$term_list .= '<li><a href="javascript:void(0)" class="'. $term->slug .'" title="'.$term->name .'">' . $term->name . '</a></li>' .'/';
    							
    							// if count is equal to i then output blank
    							if ($count != $i)
    							{
    								$term_list .= '';
    							}
    							else 
    							{
    								$term_list .= '';
    							}
    						}
    						
    						// print out each of the categories in our new format
    						echo $term_list;
    					}
    				?>
    			</ul>
    		<div class="filterable-grid column clearfix">
    			<?php
    			global $post;
    			
    			global $wp_query, $paged;
    			$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    			$the_query = new WP_Query( array( 'post_type' => 'gallery', 'posts_per_page' =>'-1', 'paged' => $paged ) );
    			$temp_query = $wp_query;
    			$wp_query = null;
    			$wp_query = $the_query; ?>
    
    			
    			<?php
    			// The Loop
    			while ( $the_query->have_posts() ) :
    				$the_query->the_post();
    				$terms = get_the_terms( $post->ID, 'gallery_category' );
    				$output = '<div class="gal-image one-third" data-id="id-'.$count.'" data-type="';
              		if ( $terms && ! is_wp_error( $terms ) ) : 
    			         foreach ($terms as $term){
    			         	$output .= strtolower(preg_replace('/\s+/', '-', $term->name)).' ';
    			         }
           			endif;
    				$output .='">';
    					if ( has_post_thumbnail() ) {
    						$large = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
    				      $output .= '<a  class="gallery-fancybox" href="' .$large[0]. '" title="' .the_title( '', '', false ). '">';
    				      $output .= get_the_post_thumbnail( $post->ID,'gallery' );
    				      $output .= '</a>';
    				   }
    				$output .= '<h3 class="custom-gallery-title">'.the_title( '', '', false ).'</h3>';
    				$output .= "</div>";
    				echo $output;
    				$count++;
    			endwhile;
    			?>
    		</div><!-- .column -->
    		<?php
    		if ( function_exists('wp_pagenavi' ) ) { 
    			wp_pagenavi();
    		}
    		else {
    			if ( $wp_query->max_num_pages > 1 ) {
    			?>
    				<ul class="default-wp-page clearfix">
    					<li class="previous"><?php next_posts_link( __( '&laquo; Previous Images', 'interface' ), $wp_query->max_num_pages ); ?></li>
    					<li class="next"><?php previous_posts_link( __( 'Next Images &raquo;', 'interface' ), $wp_query->max_num_pages ); ?></li>
    				</ul>
    				<?php 
    			}
    		}
    
    		/** 
    		 * Restore original Post Data 
    		 * NB: Because we are using new WP_Query we aren't stomping on the 
    		 * original $wp_query and it does not need to be reset.
    		 */
    		$wp_query = $temp_query;
    		wp_reset_postdata();
    		?>
    	</div><!-- #content -->
    <?php
    }
    unhook functions
    
    // Unhook default Thematic functions
    function unhook_thematic_functions() {
        // Don't forget the position number if the original function has one
    
    add_action( 'interface_gallery_three_column_template_content', 'interface_gallery_three_column_template_content', 10 );
    
    }
    add_action('init','unhook_thematic_functions');
    
    add_action( 'interface_gallery_three_column_template_content', 'interface_child_gallery_three_column_template_content', 10 );
    
     
     
    function interface_child_gallery_three_column_template_content() {      ?>   
    <div id="content">
        <ul class="gal-filter clearfix">
          <li class="active no-padding-left"><a href="javascript:void(0)" class="all" title="ALL"><?php _e('All','interface');?></a></li>/
          <?php
              // Get the taxonomy
              $terms = get_terms('gallery_category');
              
              // set a count to the amount of categories in our taxonomy
              $count = count($terms); 
              
              // set a count value to 0
              $i=0;
              
              // test if the count has any categories
              if ($count > 0) {
                
                // break each of the categories into individual elements
                $term_list ='';
                foreach ($terms as $term) {
                  
                  // increase the count by 1
                  $i++;
                  
                  // rewrite the output for each category
                  $term_list .= '<li><a href="javascript:void(0)" class="'. $term->slug .'" title="'.$term->name .'">' . $term->name . '</a></li>' .'/';
                  
                  // if count is equal to i then output blank
                  if ($count != $i)
                  {
                    $term_list .= '';
                  }
                  else 
                  {
                    $term_list .= '';
                  }
                }
                
                // print out each of the categories in our new format
                echo $term_list;
              }
            ?>
          </ul>
        <div class="filterable-grid column clearfix">
          <?php
          global $post;
          
          global $wp_query, $paged;
          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
          $the_query = new WP_Query( array( 'post_type' => 'gallery', 'posts_per_page' =>'-1', 'paged' => $paged ) );
          $temp_query = $wp_query;
          $wp_query = null;
          $wp_query = $the_query; ?>
    
          
          <?php
          // The Loop
          while ( $the_query->have_posts() ) :
            $the_query->the_post();
            $terms = get_the_terms( $post->ID, 'gallery_category' );
            $output = '<div class="gal-image one-third" data-id="id-'.$count.'" data-type="';
                  if ( $terms && ! is_wp_error( $terms ) ) : 
                   foreach ($terms as $term){
                    $output .= strtolower(preg_replace('/\s+/', '-', $term->name)).' ';
                   }
                endif;
            $output .='">';
              if ( has_post_thumbnail() ) {
                $large = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
                  $output .= '<a  href="'.get_permalink().'" title="' .the_title( '', '', false ). '">';
                  $output .= get_the_post_thumbnail( $post->ID,'gallery' );
                  $output .= '</a>';
               }
            $output .= '<h3 class="custom-gallery-title"><a href="'.get_permalink().'">'.the_title( '', '', false ).'</a>' .'</h3>';
            $output .= "</div>";
            echo $output;
            $count++;
          endwhile;
          ?>
        </div><!-- .column -->
        <?php
        if ( function_exists('wp_pagenavi' ) ) { 
          wp_pagenavi();
        }
        else {
          if ( $wp_query->max_num_pages > 1 ) {
          ?>
            <ul class="default-wp-page clearfix">
              <li class="previous"><?php next_posts_link( __( '&laquo; Previous Images', 'interface' ), $wp_query->max_num_pages ); ?></li>
              <li class="next"><?php previous_posts_link( __( 'Next Images &raquo;', 'interface' ), $wp_query->max_num_pages ); ?></li>
            </ul>
            <?php 
          }
        }
    
        /** 
         * Restore original Post Data 
         * NB: Because we are using new WP_Query we aren't stomping on the 
         * original $wp_query and it does not need to be reset.
         */
        $wp_query = $temp_query;
        wp_reset_postdata();
        ?>
      </div><!-- #content -->
      <?php 
    }

    Hope this may help you

    Thank you!

    #13409
    Peer
    Member

    That’s really cool, thanks alot!

    One issue; it seems like I cannot unhook the old code for the gallery: I get 3 photos with new links, perfect!

    Beneath, 3 photos with the old “lightbox” edition, no so good 🙂

    Can there be a issue within my functions.php in my child theme?

    Thanks again.

    #13410
    Peer
    Member

    Btw. where is the Gallery custom post type registered? Wanna change the slug 🙂

    #13460

    Hi Peer.

    Yes there may be some issue in your child theme functions.php, If you are unable to fix then you may hire a developer to fix the issue. We support only the theme regarding issues.

    The Gallery custom post type is registered inside theme folder (interface-pro) -> inc -> admin -> interface-custom-post-type.php

    Thank you!

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