Descriptions in Spintax

#1063620
  • Resolved Leroy
    Rank Math free

    I have been going crazy with getting my spintax to work in the titles, descriptions, and img alt txt when using MPG in RankMath. I’m not sure where to edit in the Rank Math program, as suggested, or also in the on-page Rank Math SEO under the edit snippet. I got the title working with %randomword_np code, but it did not do the same when I put it in the page descriptions on the RankMath program or the on-page SEO snippet.

    Also, the img alt txt I am using is Themeisle mpg, so I got a project with city being the thing that changes, and it is {{mpg_city}} shortcode that is throughout the page. How do I get Rank Math to give a different city for each generated page? Thanks in advance.

    Also, I know I got the title working by changing brackets to ( ) from { }, which is correct. The rest of the page is using curly brackets, and where do I make changes in RankMath settings, or both settings, and online SEO? Please give me a full layout, and I will follow it

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

    I apologize for the issue you are facing with getting your spintax to work in Rank Math. Thank you for raising this concern.

    To use spintax effectively in Rank Math for titles, descriptions, and image alt text, here’s a step-by-step guide:

    1. Using Spintax in Titles and Descriptions

    • Access the Meta Box: In the post-editing screen, locate the Rank Math Meta Box. If you’re using the Classic Editor, scroll down to find it. For the Block Editor, click the Rank Math SEO icon at the top-right corner.
    • Edit Snippet: Click on the Edit Snippet option in the General tab of the Meta Box. Here, you can enter your title and description.
    • Spintax Format: Ensure you are using the correct format for spintax. You mentioned that changing brackets from {} to () worked for titles. For descriptions, make sure to follow the same format. For example:
      • Title: (Title1|Title2|Title3)
      • Description: (Description1|Description2|Description3)

    2. Using Spintax in Image Alt Text

    • Image SEO Module: Ensure that the Image SEO module is enabled in Rank Math. You can do this by navigating to Rank Math SEO → General Settings → Images and toggling on the relevant options.
    • Dynamic Alt Text: For dynamic alt text using your {{mpg_city}} shortcode, you may need to manually set this in the image settings or use a custom function if Rank Math does not automatically parse shortcodes in alt text fields.

    3. Where to Make Changes

    • Rank Math Settings: Most of your changes will be made directly in the Rank Math Meta Box for each post/page. Ensure that you are editing the correct fields for titles, descriptions, and alt text.
    • On-page SEO: The on-page SEO settings should reflect any changes you make in the Meta Box. If you are using shortcodes, ensure they are supported by Rank Math or consider using PHP functions to generate dynamic content.

    4. Testing Your Setup

    • After making these changes, preview your pages to ensure that the titles, descriptions, and alt texts are displaying as expected. You can also check the source code of your pages to verify that the correct spintax is being rendered.

    If you continue to experience issues with specific settings or functionality, please reply to this ticket with your site URL so that a human agent from our support team can assist you further.

    Thank you for your patience, and we hope this helps you set up your spintax correctly!

    Sources:
    Using Variables in the SEO Title and Description » Rank Math
    Using Variables in the SEO Title and Description » Rank Math

    Leroy
    Rank Math free

    Yes I have tried this all different ways and I got the titles working The thing is with the description I am putting the spintax in there and I tried five six different ways through the rank mass settings and also the rank mat snippet and the only thing I can get it to do is if I put it the same way I have it exactly in the title It works but as soon as I tried to add more words to it that’s where it cuts off and it starts putting up the brackets again when I look at the source code or press control U. It’s has been driving me but again it’s the description and the alt text that I cannot get correctly working. I thought we had to do other stuff in the post pages Well mine’s is a page but none of that has worked so I don’t know what it is I’m missing but I’m anxious to get it figured out because it’s holding up my project all the way thank you in advance. Leroy

    Leroy
    Rank Math free

    I think the main problem I’m having in descriptions is I can get a duplicate of my title and put it there and it will show up and it will spin it but it’s only one set of brackets for a set of words when I go to the next brackets for the next words that’s where it cuts it all off and puts the spintex in the description totally. So it’s not letting me do more than one set of words or one phrase and then it goes back to putting the spintax in. Then I also followed what you had said on the alt text images but when I press control U It still showing {{MPG_City}} instead of putting in the city for that page from the multiple page generator Themeisle

    Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    In our meta fields, we don’t accept variables with curly braces. We only accept the ones with %..%. We suggest you create a custom variable where you can include it in the description meta in our plugin. Here’s an example filter code you can follow to create a custom variable for your MPG_City field:

    /**
     * Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
     * Snippet to register variable that will return all terms in custom taxonomy
     */
    add_action('rank_math/vars/register_extra_replacements', function () {
    	rank_math_register_var_replacement(
    		'shortcode_var_name',
    		[
    			'name'        => esc_html__('Author name', 'rank-math'),
    			'description' => esc_html__('Author description', 'rank-math'),
    			'variable'    => 'shortcode_var_name', /* the actual variable: %shortcode_var_name% */
    			'example'     => shortcode_var_name_call_back(),
    		],
    		'shortcode_var_name_call_back'
    	);
    });
    function shortcode_var_name_call_back() {
    	return "your variable value here...";
    }

    You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Don’t hesitate to get in touch with us if you have any other questions.

    Leroy
    Rank Math free

    Okay right now my issue is the image alt attribute. I looked up AI and I found a way to do the description and the title and now it’s very clean no problem it’s changing like it’s supposed to but the image alt attribute is what I’m not able to figure out. I’m using Google docs where it’s feeding from and pages are being generated with MPG so I’m trying to figure out what do I got to put where in rank math images in order for it to pull dynamic variables like if my keyword is Dallas website design I need Dallas to change to every city when the page pops up because I got pages in every city in the United States so the description and title is doing that right now but the image is not showing so what would I put in the image settings in rank map do you feel to make that work

    Leroy
    Rank Math free

    If need be I can get you guys a login if you feel it’s something that you would know kind of simple and then I can duplicate it? Just let me know. I know you guys deal with this stuff all the time but I really don’t but once I see it once I can duplicate it because I have five different sites that I’m using this multiple page generator on and also rankmath

    Hello,

    Rank Math doesn’t dynamically replace curly-brace shortcodes like in the Image SEO settings as well. To achieve dynamic alt text, you’ll need to generate the final alt attribute directly within your page content using MPG’s shortcodes, or programmatically modify the image alt tags using a filter in your theme.

    Unfortunately, this isn’t something Rank Math handles automatically at the moment.

    Don’t hesitate to get in touch with us if you have any other questions.

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

The ticket ‘Descriptions in Spintax’ is closed to new replies.