:::: MENU ::::

OpenGraph Image for Yoast SEO WordPress plugin

Sort of:

add_filter( 'wpseo_opengraph_image', 'my_gv_wpseo_opengraph_image', 10, 1 );
function my_gv_wpseo_opengraph_image( $img ) {
    if( ! function_exists('gravityview_is_single_entry') || ! function_exists( 'gravityview_get_entry') ) {
        return $img;
    }
    // get single entry id
    $entry_id = gravityview_is_single_entry();
    if( empty( $entry_id ) ) {
        return $img;
    }
    $entry = gravityview_get_entry( $entry_id );
    $form_id = empty( $entry['form_id'] ) ? '' : $entry['form_id'];
    switch ( $form_id ) {
        // Customise to your own case FORM ID
        case '254':
            // Customise to your own FIELD ID
            $img_field = '14';
            break;
    }
    if( !empty( $img_field ) && isset( $entry[ $img_field ] ) ) {
        $img = $entry[ $img_field ];
    }
    return $img;
}

Оставить комментарий