Add custom field for link to Essential Grid


I am trying to add a meta field for a link made in Advanced Custom Fields to an Essential Grid skin. I’ve created the ACF field and (with your help) got it to display on the single post and category pages by adding this code to the _content.php file.

<?php $link = get_field('trailer'); if( $link ): $link_url = $link['url']; $link_title = $link['title']; $link_target = $link['target'] ? $link['target'] : '_self'; ?>
<a class="button" href="<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?></a>
<?php endif; ?>

Now I would like to display this button (or link) in an Essential Grid skin. I’ve created an ES alias (egl-trailer), and added a meta field for this alias to the skin. But the field doesn’t display properly, and I can’t get it to link to the URL in the ACF link. (If I use _trailer as the meta field in the ES skin, a proper button displays, but with the wrong title, and again, it doesn’t link to the URL.)

Here’s a page with the ACF field for “trailer” properly displayed:

Here’s the page where I’m trying to get the link to display. It now shows as a tiny red button next to “Get more details.”

As an alternative approach, I can create an ACF group with a text field for the URL and a text field for the title, and I can get Essential Grid to display the title with the right URL. But this will require re-doing the code for the _content.php. If that’s a better approach, can you help with the new code to display the link in single post and category pages?

Thanks for any help you can provide.

Hi Steve,

Thanks for writing in.

Try updating in the source tab, the source to Text/HTML and Trailer as the text.

And update this in the link tab, set link to to meta and meta key to the alias you create egl-trailer

If it still doesn’t work after updating to this settings, can you be able to create a temporary credential for us in a secure note to your staging site? So that we can help you further.


Thanks for your help. Changing the source to text/html definitely helped created the link button to what it should be. But the link URL isn’t working with the alias I’d created. I will send the login credentials in a separate reply. Thanks again.

Hi Steve,

Looks like Essential Grid can’t handle fields that returns arrays yet. Let’s try the approach which you suggested.

Name the URL to trailer_url & the text to trailer_title and update the code which shows the button in the content to:

$trailer_url= get_field('trailer_url');
$trailer_title= get_field('trailer_title');
if( $trailer_url): 
    $link_target =  '_self';
    <a class="button" href="<?php echo esc_url( $trailer_url); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $trailer_title); ?></a>
<?php endif; ?>

Let us know how it goes.


That worked like a charm. The Essential Grid link worked properly, and the button appears correctly on the single post and archive pages. Thank you so much for your expert help. Your support is the best.

We are delighted to assist you with this.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.