How to have a title and meta description model

#283437
  • Resolved Alex Alex
    Rank Math free

    Hello there,

    I’ve been looking for a way to set up model of title and meta description.
    I made an Elementor model that I assigned to some pages on my WordPress that have a special category (downloaded a plugin to set up categories for pages).
    The thing is that the “SEO” tab from Rank Math that shows up on pages doesn’t show up on Elementor model.

    I’m using ACF to set up the content with shortcode such as “Mobile App creation at [acf field=”city_name”]”.
    I would like to do the same with the title and meta-description and I’ve been unable to find out if Rank Math has a function to do so.
    Any idea how to do that ?

    Thanks in advance.

Viewing 16 replies (of 16 total)
  • Hello,

    We would love to help you further.

    You can try the following code to output the value of that custom field in a variable called %field-city_name%:

    // Custom variable for the custom field from the wp_postmeta table
    
     add_action( 'rank_math/vars/register_extra_replacements', function(){
       rank_math_register_var_replacement(
           'field-city_name',
           [
            'name' => esc_html__( 'Field City Name', 'rank-math' ),
            'description' => esc_html__( 'Get the field city name from database', 'rank-math' ),
             'variable' => 'field-city_name',
             'example' => 'field_city_name_callback()',
           ],
           'field_city_name_callback'
       );
    });
    function field_city_name_callback() {
       return get_post_meta(get_queried_object_id(), 'city_name', true);
    }
    

    To know, how to insert the code on your website. Please follow the steps from this Knowledge Base article here:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    We hope this information helps. If you need further assistance, please don’t hesitate to contact us.

    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 16 replies (of 16 total)

The ticket ‘How to have a title and meta description model’ is closed to new replies.