Looper Support for Accessing GeoDirectory Custom Fields Cont

Following up on this topic: Looper Support for Accessing GeoDirectory Custom Fields

Here’s a clearer rewording of your message:


I tried using [gd_post_meta key="instagram" show="value-raw" font_size="0"] inside a text block, and it works as expected. However, when I try to use it in the Button Link URL field, it doesn’t work.

Is there a way to define all the variables in one place and reuse them across the Single Layout Template? For example:

{% set fburl = geodir_get_post_meta(post.id, "facebook", true) %}
{% set instaurl = geodir_get_post_meta(post.id, "instagram", true) %}

Since the shortcode doesn’t work inside the Button URL field, I’ve been using something like this instead:

{% set fburl = geodir_get_post_meta(post.id, "facebook", true) %}
{{ fburl }}

But if I want to conditionally display the button only when the Facebook link exists, I have to use a Twig condition like {% set fburl = geodir_get_post_meta(post.id, "facebook", true) %} {% if fburl %} — which works, but becomes a bit annoying to manage, and I’m not entirely sure if it’s fully supported in all cases.

Hello @sbxstrategies,

Thank you for following up.

We tried logging in, but the password for the username is incorrect. Please double-check the login info. Regarding the GD dynamic template, you should be able to call the geodir_get_post_meta function directly without assigning it to a variable.

Example:

{{ geodir_get_post_meta(post.id, "facebook", true) }}

Unfortunately, there’s no option to define all variables in a single place and reuse them across different areas of the template.

To display the element conditionally, you can use the default Customize > Conditions settings, perhaps using the String type with the value “{{ geodir_get_post_meta(post.id, “facebook”, true) }} > in > facebook”.

Let us know if you need more info.

Best regards.