Title droplist

#21136
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math today.

    Yes this is possible, you can add a custom replacement variable by hooking into the following filter in your theme and adding your custom logic:

    /**
     * Filter to add custom variables
     */
    add_filter( 'rank_math/vars/replacements', function( $vars ) {
     return $vars;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Whoua that’s super !

    Is there a way to add the focused keyword too ?
    Like :

    /**
     * Filter to add custom variables
     */
    add_filter( 'rank_math/vars/replacements', function( $vars ) {
    
    $vars = "That's a super".$focused_keyword." tips"
     return $vars;
    });

    ?

    Hello,

    Thank you for getting back to us.

    The focus keywords are saved in custom fields and you can get the value from the current post using the following logic:

    
    global $post;
    $focus_keywords = get_post_meta($post->ID,'rank_math_focus_keyword',true);
    

    I can also suggest that you take a look at this topic for some examples of how to register unique variables:
    https://support.rankmath.com/ticket/register-a-custom-template-variable/

    Looking forward to helping you. Thank you.

    ​​​​​​

    Jérémy R
    Rank Math free

    Hello,

    When i add the function in my function.php
    http://prntscr.com/q1sxr4

    I have no more the dropdown list :
    http://prntscr.com/q1sy0d

    What can i do ?

    Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank Math and sorry for the delay in getting back to you.
    Your last response was unfortunately stuck on our moderation queue and this is why we could not get back to you sooner.

    Back to the issue, your snippet would not work since it is not complete. You need to register your custom replacement variable and a function to get this value. Here is a better example:

    add_action( 'rank_math/vars/register_extra_replacements', function() {
       RankMath\Helper::register_var_replacement( 'variableName',array('RMcustomVariableNameCallback'),$args = array(
    	        'name'    => esc_html__( '', 'rank-math' ),
    			'desc'    => esc_html__( ', 'rank-math' ),
    			'example' => esc_html__(RMcustomVariableNameCallback())));
    	
    	
    } );
    
    function RMcustomVariableNameCallback(){
    	//do something here and return the replacement variable value
            return $value;
    	
    }

    Looking forward to helping you. 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 5 replies - 1 through 5 (of 5 total)

The ticket ‘Title droplist’ is closed to new replies.