Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marcin Pietrzak

    (@iworks)

    hi @ku3hn

    You can use og_og_image_value filter.

    Example:

    
    add_filter( 'og_og_image_value', 'my_own_og_image_value' );
    function my_own_og_image_value( $value ) {
        if ( is_admin() ) {
            return $value;
        }
        if ( is_singular() ) {
            $post_id = get_the_ID();
            $cf = get_post_meta( $post_id, 'my_own_image', true );
            if ( ! empty( $cf ) ) {
                $value = $cf;
            }
        }
        return $value;
    }
    

    Ofc, you need to change my_own_image the custom field name or replace by some more sophisticated functionality.

    I hope you enjoy with this piece of code.

    Marcin

    Thread Starter ku3hn

    (@ku3hn)

    Hi @iworks wow, thx for the fast reply.
    I love the solution! ??
    Daniel

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘og:image via custom field’ is closed to new replies.