Primary

Open Graph Protocol Framework

Make your content look great when shared on social media. Automatically controls how your posts and pages appear on Facebook, X, and other social platforms.

Description

The Open Graph Protocol enables any web page to become a rich object in a social graph. For instance, this is used on Facebook to allow any web page to have the same functionality as any other object on Facebook.

The Open Graph Protocol Framework WordPress plugin is aimed at automating the process of adding basic and optional metadata to a site’s pages. It is also designed to act as a framework for other plugins or themes and allows to modify and adapt the information provided as needed.

Usage

Install and activate the plugin. It will automatically render the following metadata for posts, pages, etc. :

  • og:title : The page’s title is used, this provides the title for posts, pages, archives etc.
  • og:type : The type will be article in general, website for the front page and blog for the blog homepage.
  • og:image : For post types that support featured images, the URL of the featured image is used. A fallback image can be chosen in the plugin’s settings, which will be used if a post does not have a featured image. Additional metadata is added, including:
    – og:image:width
    – og:image:height
    – og:image:url
    – og:image:secure_url
    – og:image:alt
  • og:url : The URL of the current page.
  • og:site_name : The name of the site.
  • og:description : Uses the full excerpt if available, otherwise derives it from the content. For author and archive pages, the type of page and title is used.

Settings

You will find the plugin’s settings under the OGP menu:

The plugin allows you to choose a fallback image which is used when no featured image is set for shared pages, posts, etc. This helps to maintain a visually consistent experience on social platforms and feeds.

Here you can choose an image that is used on social networks if no featured image is set for a shared page.

This image serves as your site-wide fallback for og:image Open Graph Protocol tags. It can help to maintain a visually consistent experience on social feeds, even if an author forgets to assign a featured image to a post, page, etc.


Developers

The plugin is also intended as a framework for developers who wish to enhance or customize aspects of the generated open graph tags. As a normal users who is not intending to code with the framework, you can skip this section.

Constants

OPEN_GRAPH_PROTOCOL_DEBUG

The OPEN_GRAPH_PROTOCOL_DEBUG constant can be used to enable debug traces where meta tags are generated by the extension. If enabled, meta tags generated by the plugin will have <!-- OFPF x.y.z --> appended, where x.y.z is the version of the plugin. To enable, add this line to your site’s wp-config.php:

define( 'OPEN_GRAPH_PROTOCOL_DEBUG', true );

… before the line that says:

/* That's all, stop editing! Happy blogging. */

Note that you do not need to set this constant, unless you want those traces to be added for debugging purposes.

Filters

The plugin provides the following filters:

open_graph_protocol_meta

This filter allows to modify the value of the content attribute for a given meta tag. It is invoked for every supported type of metadata.

Parameters:

  • string content – the current value of the content attribute
  • string property – the metadata name, for example og:title

Filters must return:

  • string the desired value of the content attribute

open_graph_protocol_meta_tag

This filter allows to modify the actual HTML <meta> tag that is rendered in the <head> section of pages.

Parameters:

  • string HTML <meta> tag
  • string property – the metadata name, for example og:title
  • string content – the value of the content attribute

Filters must return: – string the desired output for the HTML <meta> tag

open_graph_protocol_meta_tag_suffix

This filter allows to modify the suffix that is appended to each meta tag. By default, this adds a newline character.

Parameters:

  • string suffix (defaults to the newline character)

Filters must return: – string the desired suffix

open_graph_protocol_metas

This filter allows to add or remove metadata before it is rendered.

Parameters:

  • array of metadata indexed by metadata name

Filters must return: – array of metadata indexed by metadata name

open_graph_protocol_echo_metas

This filter allows to modify the HTML that renders the plugin’s meta tags in the <head> section.

Parameters:

  • string HTML with <meta> tags to be rendered

Filters must return: – string HTML with <meta> tags to be rendered