FidoSysop Blog

Removing Open Graph Output On WordPress Pages

Are you using SimplePress the WordPress forum plugin? If so chances are open graph default page data is preventing properly sharing simple press forum posts.

There are times when open graph tags output need to be removed from WordPress pages. Using Simple Press WordPress forum is one of them.

One example is if you are using a plugin for a forum or other task that does not support open graph. In this case i am using SimplePress forums that are a WordPress plugin. The reason to remove open graph output on pages is for proper social network sharing.

In this case the WordPress page that runs the application will generate default open graph output for the WordPress Page that is scraped as a default.

When you try to share a simple press web forum post on say Facebook, Facebook scrapes the page default open graph data skipping the forum post.

Inorder to make this work with Simple Press you need to disable open graph output on your simple press forum page.

Insert this this code into your “functions.php” theme file.

Note: Substitute the (8199) above for the number of the WordPress page you want to remove open graph from.

function daisychain_remove_open_graph() {
if ( is_page( 8199 ) ) {
remove_action( 'wp_head', 'daisychain_fb_thumb' );
remove_action( 'wp_head', 'daisychain_open_graph' );
}
}
add_action('template_redirect', 'daisychain_remove_open_graph', 100);

If you would like to use it for more than one page, just edit it in this way.

function daisychain_remove_open_graph() {
if ( is_page( 8199 ) || is_page( 123 ) || is_page( 456 ) ) {
remove_action( 'wp_head', 'daisychain_fb_thumb' );
remove_action( 'wp_head', 'daisychain_open_graph' );
}
}
add_action('template_redirect', 'daisychain_remove_open_graph', 100);

That will remove open graph output on your SimplePress forum page.

These snippets are for a theme i use on another blog called DaisyChain a fine WordPress theme. You will probably have to modify this code for your present theme.

Any questions? Comment below 😉