OG

Description

This is a simple, tiny plugin to produce og:tags. Just that and only
that. No configuration, pure power.

Plugin grabs data from content and if contains YouTube URL, then plugin
try to get movie thumbnail and use it in og:image.

If post contains YouTube links, this plugin saves as post meta video
thumbnail link and add it to og:image as post thumbnail.

The Facebook Open Graph Tags inserted by this plugin are:

for all type of content

  • og:locale – site locale
  • og:site_name – blog title
  • og:title – post/page/archive/tag/… title
  • og:url – the post/page permalink
  • og:type – “website” for the homepage, “article” for single content and blog for all others
  • og:description – site description
  • og:site_name – site name

for single content

  • og:image: From a specific custom field of the post/page, or if not set from the post/page featured/thumbnail image, or if it doesn’t exist from the first image in the post content, or if it doesn’t exist from the first image on the post media gallery, or if it doesn’t exist from the default image defined in the options menu. The same image chosen here will be used and enclosure/media:content on the RSS feed.
  • article:author – author of post link
  • article:published_time – date of first article publication
  • article:modified_time – date of last article modification
  • article:tag – tags used in post

Installation

There are 3 ways to install this plugin:

The super easy way

  1. Log in to your WordPress Admin panel.
  2. Go to Plugins > Add New.
  3. Type ‘OG’ into the Search Plugins field and hit Enter. Once found, you can view details such as the point release, rating, and description.
  4. Click Install Now. After clicking the link, you’ll be asked if you’re sure you want to install the plugin.
  5. Click Yes, and WordPress completes the installation.
  6. Activate the plugin.
  7. That’s all. The plugin does not have any configuration.

The easy way

  1. Download the plugin (.zip file) on the right column of this page
  2. In your Admin, go to menu Plugins > Add
  3. Select button Upload Plugin
  4. Upload the .zip file you just downloaded
  5. Activate the plugin
  6. That’s all. The plugin does not have any configuration.

The old and reliable way (FTP)

  1. Upload OG folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. That’s all. The plugin does not have any configuration.

FAQ

I installed OG and … nothing happen!

Please be patient, sometimes you need more a day to see results. The reason
of this is cache on Facebook. But check your plugins too and if you use
and caching plugins, try to do “flush cache” on your site.

How to filter values?

Use auto filters. If you have value like this:

<meta property="og:title" content="WordPress Trunk" />

Then auto filter is created like this:

og_ + (word before “:”) + _ + (word after “:”) + _value

In this case:

og_og_title_value

add_filter('og_og_title_value', 'my_og_og_title_value');
function my_og_og_title_value($title)
{
    if ( is_home() ) {
        return __('This is extra home title!', 'translate-domain');
    }
    return $title;
}
How to filter whole meta tag?

Use auto filters. If you have value like this:

<meta property="og:title" content="WordPress Trunk" />

Then auto filter is created like this:

og_ + (word before “:”) + _ + (word after “:”) + _meta

In this case:

og_og_title_meta

add_filter('og_og_title_meta', 'my_og_og_title_meta');
function my_og_og_title_meta($title)
{
    if ( is_home() ) {
        return '<meta property="og:title" content="WordPress Title" />';
    }
    return $title;
}
How to setup default image?

Use filter “og_image_init”:

add_filter('og_image_init', 'my_og_image_init');
function my_og_image_init($images)
{
    if ( is_front_page() || is_home() ) {
        $images[] = 'http://wordpress/wp-content/uploads/2014/11/DSCN0570.jpg';
    }
    return $images;
}
How to setup image on the front page?

Use filter “og_image_init”:

add_filter('og_og_image_value', 'my_og_og_image_value');
function my_og_og_image_value($images)
{
    if ( empty($images) ) {
        $images[] = 'http://wordpress/wp-content/uploads/2014/11/DSCN0570.jpg';
    }
    return $images;
}

Reviews

It’s perfect

Very simple, it works perfectly. 🙂

Only if it can fix the tag itemprop image because the Validator display this tag as error.

I have removed this line from my blog:
printf( '<meta itemprop="image" content="%s" />%s', $src, PHP_EOL );

Now is ok. 🙂

Just works!

It’s a nice plugin. Very simple. It works fine on blog posts, but for Pages it does not. For Pages, it gives OG meta data for the site instead of the page.

And twitter:description can be very long.

Update:
The author fixed the above problems. Now it works great. Thank you so much.

Remove Author

Hi i want to remove author tag that span in my feature image.

https://drive.google.com/file/d/0B_JepJ9hpW4jSXdwMnJQeWs5d1E/view?usp=sharing

thanks for your amazing plugin

Best Regard,
Nareach

tabbed content WordPress page not sharing perfectly

hi
My problem is- I have created some tabbed content WordPress page and like to share those specific content in social media. I saw other website have this SOCIAL SHARING BUTTON in tab content. now problem is that I have put short code in every tab but data doesn’t sharing perfectly, always share top content of pages . This page I have more then 2 content but it share same top content then other. This is my website link of tab content (which i don’t have sharing button) http://islambd.rubsanjida.byethost4.com/wp/%E0%A6%95%E0%A7%81%E0%A6%B0%E0%A6%86%E0%A6%A8-%E0%A6%93-%E0%A6%B9%E0%A6%BE%E0%A6%A6%E0%A7%80%E0%A6%B8%E0%A6%97%E0%A7%8D%E0%A6%B0%E0%A6%A8%E0%A7%8D%E0%A6%A5/%E0%A6%B8%E0%A6%B9%E0%A6%BF%E0%A6%B9%E0%A7%81%E0%A6%B2-%E0%A6%AC%E0%A7%81%E0%A6%96%E0%A6%BE%E0%A6%B0%E0%A7%80/%E0%A6%93%E0%A7%9F%E0%A6%BE%E0%A6%B9%E0%A7%8D%E2%80%8C%E0%A7%9F%E0%A7%80%E0%A6%B0-%E0%A6%B8%E0%A7%82%E0%A6%9A%E0%A6%A8%E0%A6%BE/
and this is the example page i am looking for (which have sharing button in tab content and share exact data in in every separate tab)- http://hadithbd.com/show.php?BookID=12&SectionID=198
it will be really helpful if any expert can solve my problems Best Regards Dr.rubel

Read all 5 reviews

Contributors & Developers

“OG” is open source software. The following people have contributed to this plugin.

Contributors

“OG” has been translated into Polish. Thank you to the translators for their contributions.

Translate “OG” into your language.

Interested in development?

Browse the code or subscribe to the development log by RSS.

Changelog

2.4.1 (2016-10-26)

  • Fixed problem for pages and another single content. At this moment OG works for all types of single entries.
  • Added ask for rating on plugins page.
  • Short twitter description.

2.4 (2016-04-10)

  • Fixed the problem with properly preparation for localization.
  • Fixed the profile with grabbing YouTube image.
  • Implement WordPress code standard for PHP code used in the plugin.

2.3 (2016-02-03)

  • Added categories as og:section.
  • Added esc_attr to headers tags.
  • Added msapplication-TileImage.
  • Added og:site_name.
  • Added profile:first_name, profile:last_name & profile:username props for Arek
  • Added tags.
  • Added twitter tags.
  • Added usage of site icon when is no icon – all cases.

2.2 (2015-08-19)

  • IMPROVEMENT: added the site icon as og:image for the home page.

2.1 (2015-05-21)

  • IMPROVEMENT: added checking site locale with facebook allowed locale.

2.0 (2014-12-11)

  • IMPROVEMENT: added check to post_content exists for CPT without this field.
  • IMPROVEMENT: added og:author link
  • IMPROVEMENT: big refactoring
  • IMPROVEMENT: added filters, see FAQ section

1.0 (2014-10-02)

Init.