ACF Global Field Support

#202612
  • Resolved Rainforest Cruises
    Rank Math pro

    Hi guys, looking to use ACF global fields as custom fields in page titles. For example we have a global custom text field called “years” (which looks like “2021/22” – we’re a travel company you see and want to show the years our tours are available) which I’d like to append to page titles using your %customfield(years)% variable. Is this possible or does the customfield variable not work with ACFs global (options page) fields?

    We have ACF integrated/activated but can’t seem to pull these global fields through.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    We have ACF integrated/activated but can’t seem to pull these global fields through.

    Are you using a stand-alone plugin for your ACF? Or it is bundled with your theme/builder?

    Also, have you enabled the ACF module in Rank Math > Dashboard?
    Rank Math ACF

    However, you can also create a custom variable using this filter:
    https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-variables

    I hope that helps.

    Thank you, and looking forward to your update.

    Hi Reinelle,
    It’s stand alone ACF, and yes the ACF option in RankMath is active.
    Should the global variables already appear, or do we have to use the filter you linked to? Will that definitely work with global variables?

    Ankit
    Rank Math business

    Hello,

    Thank you for your reply.

    Since you are using stand-alone ACF, I would suggest you try with the %customfield(years)% variable. also as my colleague mentioned you can also use the hook to add extra variables to the Rank Math dropdown in Title & Meta Settings.

    add_action( 'rank_math/vars/register_extra_replacements', function(){
            rank_math_register_var_replacement(
                    'amount_cars',
                    [
                            'name'        => esc_html__( 'Total amount of cars', 'rank-math' ),
                            'description' => esc_html__( 'Output total amount of cars.', 'rank-math' ),
                            'variable'    => 'amount_cars',
                            'example'     => get_field('amount_cars', 'option'),
                    ],
                    get_field('amount_cars', 'option')
                    );
    });

    Do let us know how that goes. Thank you.

    From your reply you suggest that using %customfield(years)% can be used without having to use the hook, correct?

    Simply inserting the %customfield(years)% into the page titles does NOT work (nothing gets inserted). I don’t want to get our developer to go to the trouble of configuring the hook if you do not support the GLOBAL (options page) ACF variables:[URL moved to sensitive data secion]

    Can you please check whether this is possible.

    Brian
    Rank Math free

    Hello,

    Thank you for getting back to us.

    From your reply you suggest that using %customfield(years)% can be used without having to use the hook, correct?

    Yes, this should be the case. For instance, if this custom field “years” is used within your page and it is filled with an input you gave “2021/22”, then you can use the variable %customfield(years)% in the SEO title for it to be displayed in your meta title as well.

    Please note that there is a difference between the SEO title and the Post/Page title. The use of this variable can only be applied in the SEO title.

    Having it on the Post/Page title would definitely require another custom filter. Could you please clarify where you want to use this ACF custom field?

    We are looking forward to helping you.
    Thank you.

    Yes SEO title. In RanMath widget I click Edit Snippet and it’s the first field “Title”.

    Here is the issue – you say “For instance, if this custom field “years” is used within your page …” – this custom field is NOT used in the page. That’s the point I’m trying to make. This custom field resides in the options page of ACF, it is a global field. I want to apply the custom field from the options page of ACF to individual pages.

    Is this possible?

    Hello,

    In this case, you may need to create a new custom variable and store the custom field FROM the options page. For that to happen you do need the filter provided by my colleague.

    Please try this filter and use the shortcode %shortcode_var_name%:

    add_action( 'rank_math/vars/register_extra_replacements', function(){
    	rank_math_register_var_replacement(
    	   'shortcode_var_name', [
    	   'name'        => esc_html__( 'VAR name', 'rank-math' ),
    	   'description' => esc_html__( 'VAR description', 'rank-math' ),
    	   'variable'    => 'shortcode_var_name',
    	   'example'     => shortcode_var_name_call_back(),
    	   ],
    	   'shortcode_var_name_call_back'
       );
    });
    function shortcode_var_name_call_back(){
    	return get_field('years', 'option'); /* FIELD FROM OPTIONS PAGE */
    }

    You may also refer to this ticket as well: https://support.rankmath.com/ticket/using-custom-post-fields-option-page-values/

    Here’s a demo: https://i.rankmath.com/auyV0P

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Great, thanks Jeremy – just what was needed.

    Anas
    Rank Math business

    Hello,

    We are glad we addressed your concern. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

The ticket ‘ACF Global Field Support’ is closed to new replies.