Details – put URL around Featured Hero Image

This topic contains 5 replies, has 4 voices, and was last updated by  Kiran 6 years, 8 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #418678

    jahusdtc
    Expired Member
    Post count: 162

    I would like to put the website URL around the top Hero Image on the Detail Page — i.e., a link.

    When user clicks, he/she is directed (in another tab) to the Listing’s own website.

    I figure I need either add_action or some filter to do that.

    Have been browsing through geodirectory_template_actions for “feature” or “thumbnail,” presuming that would be associated to top image.

    See this:
    geodir_action_details_micordata
    and this
    geodir_action_details_slider

    Are either of them where I need to concentrate?
    Any tips on how to accomplish this?

    Thanks in advance — presume will have to copy ALL of the associated function and just change the tiny bit I need to alter?

    #418711

    Kor
    Moderator
    Post count: 16516

    Hi there,

    Thanks for your post. I’ll pass this along to a developer.

    Thanks!

    #418726

    Kiran
    Moderator
    Post count: 7069

    Hello,

    Use following code snippet to add custom code underneath top image on detail page.

    
    
    function _gd_custom_link_on_detail_page() {
    	global $post;
    	if ( ! empty( $post ) ) {
    		// do stuff here
    	}
    }
    add_action( 'sd-detail-details-before', '_gd_custom_link_on_detail_page' );

    Kiran

    #418777

    jahusdtc
    Expired Member
    Post count: 162

    Thank you, Kiran, that did indeed add stuff beneath the top Featured Image Hero.

    Couldn’t seem to make it work to put a link around that featured image, though.

    This was my fix (done in localhost, eoh stuff is so I could search for changes.)

    Realized I actually needed to be in Supreme Directory’s geodirectory-compatibility.php to effect this change.

    From there, realized my “target” html/code was in sup_add_feat_img_head.

    Instead of doing this the very proper way, I (my bad) played with editing the geodirectory-compatibility.php, since I’m playing on localhost.

    I COULD have included this HUGE chunk of code in my functions.php, but that seemed like overkill to me. Either way, the same alterations would be made to the code.

    First, I erred and tried to put an href link around the featured-img div. Not right.

    Then, I realized that the link needed to be around the featured-area, instead.

    To implement, I did the following — just in case someone else is trying to do this.

    Above the <div class=”featured-area”> is a PHP code area.

    Into that I inserted the following to check if there IS a website stored for the detail listing place.
    If there’s a listing, we can do a link.

    Here’s the mini-code:

    
    
     if(isset($post->geodir_website) && $post->geodir_website){
              // echo 'There is a website - EOH';
              // echo 'Website value is ' . $post->geodir_website;
              $add_a_link_to_featured_image_hero = TRUE;
          }
          else{
            // echo 'There is NOT a website - EOH';
            $add_a_link_to_featured_image_hero = FALSE;
        }
    
        //Whoopee, a website URL exists!
        if ($add_a_link_to_featured_image_hero)
        {
            echo '<a href="' . esc_url($post->geodir_website) . '" target="_blank" class="eoh">';
        }

    Then, you also have to search for the string “sd-detail-details end” — that’s where you put the END of the href — presuming a website was stored.

    You check if you ADDED the start of the href with the $add_a_link_to_featured_image_hero variable.

    That section now looks like this:

    
    
    
     <!-- container end -->
                                   <?php do_action('sd-detail-details-container-after'); ?>
                               </div> <?php if ($add_a_link_to_featured_image_hero){echo '</a>';}?>
                               <!-- sd-detail-details end -->
                               <?php do_action('sd-detail-details-after'); ?>

    Hope this helps somebody!

    Kiran, you got me in the right area to start looking. Thank you!

    Is there an easier way than the above, do you think?

    #418816

    Alex Rollin
    Moderator
    Post count: 27815

    Looks good! Glad you got something, and thank you very much for sharing!

    #418876

    Kiran
    Moderator
    Post count: 7069

    It looks ok to me. You can customize either via hooks or editing in child theme functions.php. If your editing works fine then no problem in edit the child theme functions.php file.

    Kiran

Viewing 6 posts - 1 through 6 (of 6 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