Event Schema: Image Object Custom Field

  • Hi there,

    Really enjoying the plugin so far.

    I am trying to import some events using WP AllImport.

    I have found most of the rank math custom fields that I need to create the Event Schema for Google, but am missing the Image field.

    I can see rank_math_facebook_image which works fine, but there doesn’t seem to be a rank_math_snippet_event_image. As a result, the markup does not include an image object for any of the events.

    If I add the image within the post interface itself (in the Facebook image tab), the image object does get added.

    Is there a way to make the rank_math_facebook_image also act as the image object for the event schema?

    Thanks a lot in advance.

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

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

    Rank Math will get the value from the featured image. You can however create some custom PHP logic to get the value from the custom filed and assign it to the $entity[‘image’] within the following filter:

    /**
     * Filter to Short-circuit Schema if a 3rd party is interested in generating their own data.
     * Replace $schmea_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_{$schema_type}", function( $entity ) {
     return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Thanks very much for the quick reply Michael. Please could you confirm which file this custom code would need to be placed?

    As this is a custom post type, I don’t have an option to add a featured image.

    Hi Michael, just a quick follow up to say I worked out where to add the featured image and the schema is working as intended now.

    Thanks a lot for the quick reply again!

    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/?rate=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 4 replies - 1 through 4 (of 4 total)

The ticket ‘Event Schema: Image Object Custom Field’ is closed to new replies.