Field URL
-
Hi, your plugin is the best! All works well, but i want to show sites links of users in location field. I know how to rename location field, but i cant insert here clickable link like Site Please tell me how to do it?
-
Hi,
hmm i am not exactly sure what you would like to do? Do you want to show a clickable link in the [adverts_add] form or in the Ad details pages? and what the link should point to?If you want the users to view an Ad and click on the Ad location to view other ads in the same location then this is possible with the Maps and Locations extension https://wpadverts.com/extensions/maps-and-locations/
Hi, i want that user can write his site clickable URL in location field in [adverts_add] form. And in frontend of ad it will be shown too. Because i don’t use location address in my site, i use only users site URL instead address. But “location” text field dont accept clickable URL link like Site, tell me please how to make it accept?
Like this https://ibb.co/gt525YT
Hi,
the easiest way to do that would be to use the Custom Fields extension https://wpadverts.com/extensions/custom-fields/, you could use the drag and drop editor to add a new URL field to the [adverts_add] form and the entered value will automatically display as a link on the Ad details pages.One other way to do that would be to use the Forms API https://wpadverts.com/doc/custom-fields/ to add a new field and have it shown on the Ad details pages but please note this requires some PHP programming knowledge to do.
I add this code and create field “SITE”:
add_filter( "adverts_form_load", "my_adverts_form_load" ); function my_adverts_form_load( $form ) { if( $form["name"] != "advert" ) { return $form; } $form["field"][] = array( "name" => "my_custom_field", "type" => "adverts_field_text", "order" => 25, "label" => "SITE", "is_required" => true, "validator" => array( array( "name" => "is_required" ), ) ); return $form; }but URL links written at this field are not clickable. Users cant click on it just once. Maybe i should change “type”?
-
This reply was modified 4 years, 4 months ago by
linaraduzn27.
Hi,
the code you posted is for adding the field to the form, to display the link on the Ad details page you need to use the last code snippet on this page https://wpadverts.com/doc/custom-fields/ and in the code replace<?php esc_html_e( $cf ) ?>with something like
<a href="<?php esc_html_e( $cf ) ?>"><?php esc_html_e( $cf ) ?></a>Hi, i add this code:
add_action( "adverts_tpl_single_details", "my_adverts_tpl_single_details" ); function my_adverts_tpl_single_details( $post_id ) { $cf = get_post_meta( $post_id, "my_custom_field", true); ?> <?php if(! empty($cf) ): ?> <div class="adverts-grid-row"> <div class="adverts-grid-col adverts-col-30"> <span class="adverts-round-icon adverts-icon-wordpress"></span> <span class="adverts-row-title">SITE</span> </div> <div class="adverts-grid-col adverts-col-65"> href="<?php esc_html_e( $cf ) ?>"><?php esc_html_e( $cf ) ?></a> </div> </div> <?php endif; ?> <?php }But when i write in field “SITE” for example: fish.com, in the frontend in field “SITE” i see – href=”fish.com”>fish.com (and it is not clickable)
Hi,
1. please note that the linehref="<?php esc_html_e( $cf ) ?>"><?php esc_html_e( $cf ) ?></a>is incorrect you are missing
<aat the beginning it should be<a href="<?php esc_html_e( $cf ) ?>"><?php esc_html_e( $cf ) ?></a>2. also the URLs that users enter in the SITE field should start with http:// or https:// otherwise they will not redirect users properly.
To validate that the user entered URL is correct in your first snippet below the line
array( "name" => "is_required" ),addarray( "name" => "is_url" ),Thanks a lot, its great!
-
This reply was modified 4 years, 4 months ago by
The topic ‘Field URL’ is closed to new replies.