Last active
June 15, 2018 23:09
-
-
Save xnau/5f601b1b7a2de7f8547dddbbaecb1151 to your computer and use it in GitHub Desktop.
Demonstrates how to place OpenGraph meta data into a Participants Database single record display page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: PDB Add Facebook/Twitter Meta Tags | |
* Description: place metadata tags in the header of a single record page | |
*/ | |
// this will fire just before the end of the page <head> tag | |
add_action( 'wp_head', 'xnau_place_opengraph_tags', 100 ); | |
/** | |
* places the meta tags in the page head | |
* | |
*/ | |
function xnau_place_opengraph_tags () | |
{ | |
$post = get_post(); | |
/* | |
* this gets the single record page ID from the plugin settings; make sure the | |
* plugin settings are set to point to the page with your [pdb_single] shortcode | |
*/ | |
if ( $post->ID == xnau_pdb_single_record_page() ) { | |
// this prints the meta tags | |
echo do_shortcode( '[pdb_single template=opengraph]' ); | |
} | |
} | |
/** | |
* provides the ID of the single record page from the plugin settings | |
* | |
* @return string ID | |
*/ | |
function xnau_pdb_single_record_page() | |
{ | |
return Participants_Db::apply_filters( 'single_record_page', Participants_Db::$plugin_options['single_record_page'] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment