Title to link
-
Hi guys,
I found it odd to display a link text for the link to page field.
So here’s a little hack to display the title of a post to which a link field is pointing to:
public function page_link($custom_field, $acf_version, $link_text) { $page_link = $custom_field["value"]; if (!$link_text) { $link_text = get_the_title(url_to_postid($page_link)); }; $ret_val = '<a href="'.$page_link.'">'.$link_text.'</a>'; return $ret_val; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Title to link’ is closed to new replies.