Modify the name of the link on a file

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

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

Open Support Ticket
  • Author
    Posts
  • #507426

    Stephanie Rawson
    Buyer
    Post count: 13

    I have a custom field called ‘itinerary1’ that is type File. I have another custom field called ‘itinerary1_link’ that is type Text.

    In GD v1, I was able to replace the name shown when displaying ‘itinerary1’ with ‘itinerary1_link’ using the code below in my functions.php file.

    // Replace Itinerary 1 file name with link text
    add_filter("geodir_show_geodir_itinerary1","itinerary_change_link_title1", 10,2);
    function itinerary_change_link_title1($html, $variables_array){
    	global $post;
    	$link = geodir_get_post_meta($post->ID, 'geodir_itinerary1_link', true);				
    	if($parts = explode('target="_blank">',$html)){
    		$html = $parts[0].'target="_blank">'.$link.'</div></div>';
    	}
    	return $html;
    }

    How do I recreate this in GD v2?

    #507431

    Kor
    Moderator
    Post count: 16516

    Hi Stephanie,

    Thanks for your post. I will forward this to a developer for further assistance.

    #507626

    Kor
    Moderator
    Post count: 16516

    Hi Stephanie,

    Thanks for your patience. Could you please tell us a little bit more about where this code is being used and also, what are you trying to change in GDv2? Also, share your Website WP admin access here in private reply and we’ll check this out for you.

    #508105

    Stephanie Rawson
    Buyer
    Post count: 13
    This reply has been marked as private.
    #508398

    Naveen Giri
    Moderator
    Post count: 1559

    hi Stephanie ,

    the login details are not seems valid. please send valid details.

    Thanks

    #508421

    Stephanie Rawson
    Buyer
    Post count: 13
    This reply has been marked as private.
    #508562

    Kiran
    Moderator
    Post count: 7069

    Hi Stephanie,

    We have added new hook to filter filename. It will be in upcoming release probably within this week.

    You can use filter

    add_filter( 'geodir_cf_file_FIELDNAME_filename', 'gd_snippet_cf_file_FIELDNAME_filename', 20, 4 );

    Example for “itinerary1” & “itinerary1_link” fields.

    
    
    /**
     * Filter custom field "file" filename.
     */
    function gd_snippet_cf_file_itinerary1_filename( $filename, $gd_post, $file, $field ) {
        if ( ! empty( $gd_post->itinerary1_link ) ) {
            $filename = $gd_post->itinerary1_link;
        }
    
        return $filename;
    }
    add_filter( 'geodir_cf_file_itinerary1_filename', 'gd_snippet_cf_file_itinerary1_filename', 20, 4 );

    Patch available at here: https://github.com/AyeCode/geodirectory/commit/968ad09e330a54ac2f93c417eb1871ddee568e6d

    Regards,
    Kiran

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

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

Open Support Ticket