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 TicketTagged: image thumbnails, listing description, tabs
-
AuthorPosts
-
November 9, 2014 at 8:59 am #21036
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!
November 10, 2014 at 4:54 pm #21094Hi,
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
November 12, 2014 at 12:11 pm #21260Thank 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.
November 12, 2014 at 12:22 pm #21262Spoke 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; }
November 12, 2014 at 4:41 pm #21284Hi,
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
November 13, 2014 at 10:22 am #21371Hmm, 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.
November 13, 2014 at 6:13 pm #21440OK 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
November 16, 2014 at 11:06 am #21655That worked wonderfully. Thank you.
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket