Custom field with variable in Video schema Content URL

#257448
  • Resolved Mara Sec
    Rank Math free

    Hi I refer to another ticket: https://support.rankmath.com/ticket/rankmath-video-url-dl-automatic-in-content-url/

    I’ve added the relevant code in my functions.php and reference it with %wps_trailer_url% in Content Url, unfortunately when the actual page is rendered, it shows as:

    <meta property="og:video" content="%wps_trailer_url%" />

    add_action( 'rank_math/vars/register_extra_replacements', function() {
    rank_math_register_var_replacement(
    'wps_trailer_url', [
    'name' => esc_html__( 'Author name', 'rank-math' ),
    'description' => esc_html__( 'Author description', 'rank-math' ),
    'variable' => 'wps_trailer_url',
    'example' => rankmath_add_trailer_url(),
    ],
    'rankmath_add_trailer_url'
    );
    });
    function rankmath_add_trailer_url(){
    global $post;
    return get_post_meta( $post->ID, 'trailer_url', true );
    }

    Am I missing something?

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

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

    Without knowing the specifics of the database entries it’s hard to give you a complete answer, so please head over to your database postmeta table and find the field that houses the URL for the video and see if it matches what you have in code.

    Alternatively, if you can’t still return the appropriate value please provide us with WordPress login credentials so we can debug the situation further.

    Looking forward to helping you.​​​​

    Here is the custom field

    Do I have to upgrade PRO before this feature can be used?

    Hello,

    Could you please share with us the URL on your website where you are seeing this og:video property? We tried several URLs from your website and couldn’t find this anywhere.

    You can share via the sensitive data section.

    Looking forward to hearing back from you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    It seems that there is a filter or any other theme applying the OG meta tags on your website.

    In this case, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    I’ve added a user account that you can use to login and check.

    Hello,

    We believe this error is happening because it seems that your content is password protected and the video object is not actually rendered on the first-page load because of that.

    The variables are working fine on the meta description for example, which is a clear indication they are working well, but the og:video property is actually unknown when the plugin loads and thus causing this issue.

    Hope this helps clarify your doubts.

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

    Hi I do not believe this should be the case. The variable is supposed to simply get the custom field data and pushing it into the meta tag – this should happen even before the page is loaded on the browser.

    I have added a custom meta tag for twitter:player and it is able to push to the HTML even before any page load is done.

    Hello,

    We understand that and the variable of og:video that you are adding manually with the filter is returning the correct value already.

    We were talking about the automatically generated one that is returning the variable name because of the issue mentioned before.
    OG Video

    Hope this helps clarify your doubts.

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

    Understood – is there anything I can do to get the og:video tag from the plugin to work?

    Ankit
    Rank Math business

    Hello,

    Since the page is protected, The variables fails to load at first request as mentioned by my colleague you can test the same by removing the protection.

    Hope that helps. Thank you.

    Hi I’ve publicly published the post now and it made no difference

    Hello,

    We created some custom code on your website to make sure that the variable is being outputted in the og:video property and removed the duplication.

    Here’s the code snippet we used to achieve this:

    
    add_filter( "rank_math/opengraph/facebook/og_video", function( $content ) {
    	global $post;
    	
    	$trailer_url = get_post_meta( $post->ID, 'trailer_url', true );
    	
    	if ($trailer_url) {
    		$content = $trailer_url;
    	}
    	
    	return $content;
    });
    

    Now the variable is being converted to the appropriate values.

    Hope this helps solve your issues.

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

    Thanks – just to clear things up, do I still need the %wps_trailer_url% variable for Content URL or can I remove it?

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

The ticket ‘Custom field with variable in Video schema Content URL’ is closed to new replies.