Get listing description and images

This topic contains 7 replies, has 3 voices, and was last updated by  halalcompass 9 years, 11 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #21036

    halalcompass
    Expired Member
    Post count: 32

    Hello,

    I’m looking for a bit of help extracting the listing description and images so I can move them outside of the tab.

    I do not want to use the tabs on the listing detail page, but would rather have each bit of content underneath each other.

    I’ve been able to rearrange most of it using hooks, but can’t seem to find how to pull just the description and image thumbnails.

    Any help would be greatly appreciated. Thanks!

    #21094

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    listing description will be the default wordpress API for post description.

    
    
    
    <?php the_content(); ?>

    While for the post thumbs will be:

    
    
    <?php $post_images = geodir_get_images($post->ID,'thumbnail');
    		$thumb_image = '';
    		if(!empty($post_images)){
    			foreach($post_images as $image){
    				$thumb_image .=	'<a href="'.$image->src.'">';
    				$thumb_image .= geodir_show_image($image,'thumbnail',true,false);
    				$thumb_image .= '</a>';
    			}
    		}
    
    echo $thumb_image;?>

    For reference, these can be found in “function geodir_show_detail_page_tabs()” in “custom_functions.php” file starting from line 842.

    Thx

    #21260

    halalcompass
    Expired Member
    Post count: 32

    Thank you very much! This was exactly what I was looking for. I probably came across it in custom_functions.php but not knowing knowing PHP fluently, I didn’t realize I could just use that part.

    For anyone interested, I basically placed these each in their own function, and then used an action to load each piece on the page.

    #21262

    halalcompass
    Expired Member
    Post count: 32

    Spoke too soon for the image thumbnails. I used the code below, but thumbnails don’t show. Any idea where I went wrong?

    
    
    add_action('geodir_details_main_content', 'geodir_detail_page_images_hc', 31);
    function geodir_detail_page_images_hc() {
    	$post_images = geodir_get_images($post->ID,'thumbnail');
    		$thumb_image = '';
    		if(!empty($post_images)){
    			foreach($post_images as $image){
    				$thumb_image .=	'<a href="'.$image->src.'">';
    				$thumb_image .= geodir_show_image($image,'thumbnail',true,false);
    				$thumb_image .= '</a>';
    			}
    		}
    
    	echo $thumb_image;
    }
    #21284

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I think all that is needed is in function to add:

    
    
    global $post;
    

    When inside function there is not access to post unless u make it a global var.

    Please try:

    
    
    add_action('geodir_details_main_content', 'geodir_detail_page_images_hc', 31);
    function geodir_detail_page_images_hc() {
    global $post;
     $post_images = geodir_get_images($post->ID,'thumbnail');
      $thumb_image = '';
      if(!empty($post_images)){
       foreach($post_images as $image){
        $thumb_image .= '<a href="'.$image->src.'">';
        $thumb_image .= geodir_show_image($image,'thumbnail',true,false);
        $thumb_image .= '</a>';
       }
      }

    Let us know,

    Thx

    #21371

    halalcompass
    Expired Member
    Post count: 32

    Hmm, still not able to get this working. I also tried adding $post_images to the “global” but still nothing.

    Here is the latest code I’m using.

    
    
    add_action('geodir_details_main_content', 'geodir_detail_page_images_hc', 31);
    function geodir_detail_page_images_hc() {
    	global $post, $post_images;
    	$post_images = geodir_get_images($post->ID,'thumbnail');
    		$thumb_image = '';
    		if(!empty($post_images)){
    			foreach($post_images as $image){
    				$thumb_image .=	'<a href="'.$image->src.'">';
    				$thumb_image .= geodir_show_image($image,'thumbnail',true,false);
    				$thumb_image .= '</a>';
    			}
    		}
    	echo $thumb_image;
    }

    You may view the page here: http://halalcompass.com/places/toronto/schools/al-azhar-islamic-school/

    Thanks for all your help.

    #21440

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    OK this was working 100% but you have no styling applied so the divs have no dimensions, if you want standard GT styleing like in the tab just add the wrapper div like this…

    
    
    add_action('geodir_details_main_content', 'geodir_detail_page_images_hc', 31);
    function geodir_detail_page_images_hc() {
    	global $post, $post_images;
    	$post_images = geodir_get_images($post->ID,'thumbnail');
    		$thumb_image = '';
    		if(!empty($post_images)){
    			$thumb_image .= '<div id="geodir-post-gallery" class="clearfix">';
    			foreach($post_images as $image){
    				$thumb_image .=	'<a href="'.$image->src.'">';
    				$thumb_image .= geodir_show_image($image,'thumbnail',true,false);
    				$thumb_image .= '</a>';
    			}
    			$thumb_image .= '</div>';
    		}
    	echo $thumb_image;
    }

    Thanks,

    Stiofan

    #21655

    halalcompass
    Expired Member
    Post count: 32

    That worked wonderfully. Thank you.

Viewing 8 posts - 1 through 8 (of 8 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount