Title: Custom hyperlinks
Last modified: August 31, 2016

---

# Custom hyperlinks

 *  [viriato_sueco](https://wordpress.org/support/users/viriato_sueco/)
 * (@viriato_sueco)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/custom-hyperlinks-1/)
 * I have a situation where:
 *  – I need to create a custom link per image on an image gallery. I have created
   a text field with HTML outputting so that hyperlinks get converted automatically.
   –
   The user will be populating that field with the link every time a new post is
   created. – I am using a custom post type (post-portfolio). – Each post has a 
   cover image that will be a thumbnail when looking at the gallery. – Those links
   will later on be displayed as a link on the thumbnail of the image – not on the
   image’s lightbox or single-post page. – The gallery’s default behavior is to 
   have two font-awesome icons acting as buttons/links: Lightbox view and single
   post permalink. I have now added a new font awesome link/button to have that 
   text field acting as the link’s target.
 * **The code on the functions.php:**
 *  `if(function_exists(“register_field_group”))
    { register_field_group(array (‘
   id’ => ‘acf_sponsorer-lank’, ‘title’ => ‘Sponsor hyperlänk’, ‘fields’ => array(
   array ( ‘key’ => ‘field_56ea5ece13165’, ‘label’ => ‘Sponsor länk till webbsida’,‘
   name’ => ‘sponsor_lank_till_webbsida’, ‘type’ => ‘text’, ‘instructions’ => ‘Skriv
   här webbsidan till sponsorn. Om det inte finns någon webbsida skriv endast #’,‘
   required’ => 1, ‘default_value’ => ”, ‘placeholder’ => ”, ‘prepend’ => ”, ‘append’
   => ”, ‘formatting’ => ‘html’, ‘maxlength’ => ”, ), ), ‘location’ => array ( array(
   array ( ‘param’ => ‘post_type’, ‘operator’ => ‘==’, ‘value’ => ‘post-portfolio’,‘
   order_no’ => 1, ‘group_no’ => 1, ), ), ), ‘options’ => array ( ‘position’ => ‘
   normal’, ‘layout’ => ‘default’, ‘hide_on_screen’ => array ( ), ), ‘menu_order’
   => 0, )); }`
 * **The code on the gallery that shows all thumbnails:**
 *  `$variable = get_field(‘sponsor_lank_till_webbsida’, $post->post-portfolio);
 *  <div class=”acts”>
    <h3>’.get_the_title().'</h3> <a href=”‘.$url.'” title=”‘.
   get_the_title().'” class=”icon-search” rel=”prettyPhoto[gallery1]”><!—-></a> 
   <a href=”‘.the_field(‘sponsor_lank_till_webbsida’, get_option(‘acf_sponsorer-
   lank’)).'” class=” icon-h-link” target=”_blank”><!—-></a> <a href=”‘.get_permalink().'”
   class=” icon-link”><!—-></a> </div>`
 * **A note on the last bit of code I wrote:**
 * The `<div class="acts">` is inside of PHP tags, so no need to open and close 
   it there.
 * **Problem:**
 * The custom field is showing up where on the custom post type page when the admin
   creates a new post, but the link on the gallery page has no target (the value
   that the user inserts on the post creation page).
 * I have been reading the documentation and trying so many times and so many ways
   but I cannot seem to make it work. Can please somebody help me?
 * [https://wordpress.org/plugins/advanced-custom-fields/](https://wordpress.org/plugins/advanced-custom-fields/)

The topic ‘Custom hyperlinks’ is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields/assets/icon.svg?rev=3207824)
 * [Advanced Custom Fields (ACF®)](https://wordpress.org/plugins/advanced-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)
 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [hyperlink](https://wordpress.org/support/topic-tag/hyperlink/)
 * [output](https://wordpress.org/support/topic-tag/output/)

 * 0 replies
 * 1 participant
 * Last reply from: [viriato_sueco](https://wordpress.org/support/users/viriato_sueco/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/custom-hyperlinks-1/)
 * Status: not resolved