OG image - by jeremy - on WordPress WooCommerce support

This topic has 4 replies, 2 voices, and was last updated 6 years, 8 months ago ago by Rose Tyler

  • Avatar: tlgv
    jeremy
    Participant
    April 9, 2018 at 12:23

    Hello,

    I can’t find where I can change the og image in your theme.

    When I test my page with FB debugger tool, I have the result enclosed. I tried to replace your facebook image default with one of mine by putting it in my child theme, but it doesn’t work. Or can I delete your facebook image default?

    Thank you for your help.

    Please, contact administrator
    for this information.
    3 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    April 10, 2018 at 08:40

    Hello,

    Please create folder ‘images’ in child-theme and upload your custom img,
    then rewrite function et_insert_fb_in_head in functions.php file of the child theme, the function you can find in main theme/framework/theme-functions.php
    https://prnt.sc/jhlql5 – make changes as on screenshot and you will have your image on facebook share

    Regards

    Avatar: tlgv
    jeremy
    Participant
    April 10, 2018 at 17:34

    Hello,

    Thank you but it doesn’t work. I don’t have the same as you. I have the following code:

    if(!function_exists('et_insert_fb_in_head')) {
        function et_insert_fb_in_head() {
            global $post;
            if ( !is_singular()) //if it is not a post or a page
                return;
                
                $description = et_excerpt( $post->post_content, $post->post_excerpt );
                $description = strip_tags($description);
                $description = str_replace("\"", "'", $description);
                
                echo '<meta property="og:title" content="' . get_the_title() . '"/>';
                echo '<meta property="og:type" content="article"/>';
                echo '<meta property="og:description" content="' . $description . '"/>';
                echo '<meta property="og:url" content="' . get_permalink() . '"/>';
                echo '<meta property="og:site_name" content="'. get_bloginfo('name') .'"/>';
                
                if(!has_post_thumbnail( $post->ID )) { 
                    $default_image = PARENT_URL . '/images/staticks/facebook-default.jpg'; 
                    echo '<meta property="og:image" content="' . $default_image . '"/>';
                } else {
                    $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
                    echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';
                }
                echo "";
        }
    }
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    April 11, 2018 at 07:39

    Hello,

    We’ve sent you the screenshot of the code in the child theme, so check it one more time, please.

    Regards

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.