Home › Forums › General Issues › Add a special global link on top of post title › Reply To: Add a special global link on top of post title
The code I supplied will do what you are looking for, you need to add fields and then change the code to match your field names
add_filter('the_title', 'wps_sponsored', 10, 2);
function wps_sponsored($title, $post_id) {
$sub_title = get_field('sub-title-field-name', $post_id);
if ($sub_title) {
$url = get_field('sub-title-url-field-name', $post_id);
if ($url) {
$sub_title = '<a href="'.$url.'">'.$sub_title.'</a>';
}
$sub_title = '<span class="subtitle">'.$sub_title.'</span>';
$title = $sub_title.$title;
}
return $title;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.