Jakub Glodek
asked 10 years ago

I have seen other articles that point me to functions.php but I could not find the og:image parameter in that file.  Can you point me in the right direction?

2 Answers
DominicStaff
answered 10 years ago

You can open the function.php file, then add the following code under line  524.

if( ! function_exists('dw_focus_post_views') ) { 
    /**
     * Views count for a single post
     */
    function dw_focus_post_views() {
        if( is_single() ){
            global $post;
            $view = get_post_meta($post->ID, '_views', true);
            $view = $view ? $view+1 : 1;
            update_post_meta($post->ID, '_views', $view);

            echo '<meta property="og:title" content="'.get_the_title().'" />';
            echo '<meta property="og:url" content="'.get_permalink().'" />';
            if( has_post_thumbnail() ) {
                $thumb_id = get_post_thumbnail_id();
                $thumb = wp_get_attachment_thumb_url( $thumb_id );
                echo '<meta property="og:image" content="'.$thumb.'" />';   
            }
            echo '<meta property="og:description" content="'. esc_html( get_the_excerpt() ) .'"/>';
        }
    }
    add_action('wp_head', 'dw_focus_post_views');
}

Hope this helps !

Jakub Glodek
replied 10 years ago

1 thing to note, this only happens when the Plugin “Jetpack” is enabled. I now believe this to happen only when that plugin is on, and thus I don’t see this as an issue directly with this Theme.

Jakub Glodek
answered 10 years ago

OK, you can fix this issue by following these directions:
http://jetpack.me/2013/05/03/remove-open-graph-meta-tags/
Essentially you add
add_filter( 'jetpack_enable_open_graph', '__return_false' );
To your functions.php file in your theme.

Powered by DW Question & Answer Pro