Use ACF Global Options fields in Rank Math

#659476
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Apologies for the delay as we currently have a high volume of tickets here in our support forums.

    For this, you can use the variable that we have to fetch the data from custom fields: %customfield(field-name)%

    ​​​​​​​Simply replace the field-name in the variable with the name of the field where the data is present and it should update the results fine.

    Hope that helps.

    Thank you.

    Hi, I noticed that this issue is similar to the one I’m having. The above method “%customfield(field-name)%” will not work with option page acf. It only works with basic fields in the page. Can you help me review it? Thank.

    Hello,

    In this case, you may need to create a new custom variable and store the custom field FROM the options page.

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

    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('field_name', '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.

    I have tried and succeeded with this method. Thank you for your help.

    Thank you as well, this does work. I would suggest that this should be a feature update to make it native functionality.

    Hello,

    We are super happy that this resolved your issue. 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.

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

The ticket ‘Use ACF Global Options fields in Rank Math’ is closed to new replies.