timwilde
Forum Replies Created
-
Thanks for the quick response.
I set ‘Duplicate record check field’ to ‘Private_id’ and ‘Duplicate record preference’ to a ‘create a new record with the submission’ and it all worked well
Thanks again.
Forum: Plugins
In reply to: [Participants Database] PDB image into Facebook share using wpseo_opengraphHi,
I managed to get this working. Not sure how technically correct it is but it does the job.
We are a non profit that rescues dogs on the Island of Crete, Greece. We use your software to build a database of dogs that need new homes (Thanks to you and your system it saved us a load of time and looks great!)
I wanted to change the Facebook/Messenger share so that name and photo of the dog is displayed when shared out, but only from the pdb_single page ($post->ID == ’86’)Add the following to functions.php in the child theme
————————————————-
Change the image for Facebook og
————————————————-function change_image_filter() {
global $post;
if ( $post->ID == ’86’ ) {
$url=$_SERVER[‘REQUEST_URI’];
$link_array = explode(‘=’,$url);
$record_id = end($link_array);
$pdbrecord = Participants_Db::get_participant($record_id);
$dname=$pdbrecord[‘dog_name’];
$pname=$pdbrecord[‘photo’];
if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
$_head = get_posts(‘post_type=attachment&name=’.$pname.’&posts_per_page=1&post_status=inherit’);
$header = $_head ? array_pop($_head) : null;
$header_url = $header ? wp_get_attachment_image_src( $header->ID, ‘large’)[0]: ”;
$dog_image=$header_url;
return $dog_image;
}
}
}
add_filter(‘wpseo_opengraph_image’, ‘change_image_filter’,10,1);————————————————————————–
Change the Title for Facebook OG
——————————-
function change_title_filter() {
global $post;
if ( $post->ID == ’86’ ) {
$url=$_SERVER[‘REQUEST_URI’];
$link_array = explode(‘=’,$url);
$record_id = end($link_array);
$pdbrecord = Participants_Db::get_participant($record_id);
$dog_title=$pdbrecord[‘dog_name’] . ” – Needs a home”;
return $dog_title;
}
}
add_filter(‘wpseo_title’, ‘change_title_filter’,10,1);———————————-
Change the WordPress Page Title that is displayed
————————————-
add_filter( ‘pre_get_document_title’, ‘change_title_filter’, 10 );————————————
Change the Facebook OG description
————————————-
function change_desc_filter() {
global $post;
if ( $post->ID == ’86’ ) {
$url=$_SERVER[‘REQUEST_URI’];
$link_array = explode(‘=’,$url);
$record_id = end($link_array);
$pdbrecord = Participants_Db::get_participant($record_id);
$desc=$pdbrecord[‘dog_name’];
return $desc;
}
}
add_filter(‘wpseo_opengraph_desc’, ‘change_desc_filter’,10,1);————————————
Change the Facebook OG URL
————————————-function change_url_filter() {
global $post;
if ( $post->ID == ’86’ ) {
$url=get_site_url() . $_SERVER[‘REQUEST_URI’];
return $url;
}
}
add_filter(‘wpseo_opengraph_url’, ‘change_url_filter’,10,1);
——————————————————————-Hope this helps someone else..
Forum: Plugins
In reply to: [Participants Database] PDB image into Facebook share using wpseo_opengraphOk thanks for the direction. Will investigate and update later..Cheers