How to update Rank Math's new snippet variables in existing posts?

#2101
  • Resolved L
    Rank Math free

    Somewhere along the line it seems Rank Math changed snippet variables.

    Screenshot of old default variables in a single post

    Before, the variables were post_title and post_excerpt. Now they are %title% and %excerpt%. But my existing posts on all my sites still have the old variables, so the content is not populating.

    This is especially noticeable on review posts, which now in the summary block have “post_title” as the title of the block and “post_excerpt” as the content.

    Screenshot of output resulting from old default variables

    I can manually update an individual post, going in and replacing the variables one by one. But I’m looking at hundreds of posts on multiple sites, including client sites, that have broken snippets right now.

    Is there ANY way to bulk update these to the new variables? Even a wp-cli method?

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

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I would suggest that you set these options globally by heading over to Rank Math > Titles and Meta > Select your post type and set the variables and click save.

    I hope this info helps. Thank you.

    ​​​​​​​

    L
    Rank Math free

    The variables ARE set properly globally.

    But the variables the plugin previously inserted into the posts in the rank_math_snippet_desc field are not changed. This was something the plugin did. Unfortunately, the global settings don’t undo that.

    Is there any way to globally fix these?

    If not, will there be a bugfix release that will correct this?

    L
    Rank Math free

    And rank_math_snippet_name field is populated with “post_title”.

    Both of these values are visible on the page on Review snippet types.

    But these values are in the JSON injected by the plugin into the page.

    `”@context”:”https:\/\/schema.org”,”@type”:”BlogPosting”,”headline”:”post_title”,”description”:”post_excerpt”,[snip]

    I note that posts made in the past couple of weeks don’t have these injected values. However, older posts do.

    I hope these details are helpful.

    Hello,

    Thank you for the follow up.

    To fix this, you can do one of the following:
    1). Edit the database content directly, repacing all references of %post_title% to %title% in the meta_value column of the wp_postmeta table, and do the same for the other variables.

    2). You can also make use of the following snippet:

    /**
     * Filter to add custom variables
     */
    add_filter( 'rank_math/vars/replacements', function( $vars ) {
    if (isset($vars['title'])){
    $vars['title'] = 'post_title';
    }
    	return $vars;
    });

    I hope this info helps. Thank you.

    ​​​​​​

    L
    Rank Math free

    I was just writing the following when I got the notification you replied:

    A bit more debugging info and a question:

    I found the field values saved in the postmeta table.

    Question: Is it safe to assume that if I delete those erroneous values from those table rows (while leaving the table rows in place otherwise), the global default values will be applied on the posts, pages, etc?

    Your reply is much more specific. Thanks. I hope this does lead to a one-time cleanup function that will help all the non-developers facing this problem.

    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/?filter=5#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)

You must be logged in to reply to this ticket.