Skip to content

Instantly share code, notes, and snippets.

@leewillis77
Created February 25, 2019 09:41
Show Gist options
  • Save leewillis77/9076fc490e83893a048ecfee2a614561 to your computer and use it in GitHub Desktop.
Save leewillis77/9076fc490e83893a048ecfee2a614561 to your computer and use it in GitHub Desktop.
Avoid issues with extensions that abuse the_content filter
<?php
add_filter( 'woocommerce_gpf_title', function ( $title, $specific_id ) {
global $post, $gpf_original_post;
$gpf_original_post = $post;
$post = get_post( $specific_id );
setup_postdata( $post );
return $title;
}, 10, 2 );
add_filter( 'woocommerce_gpf_description', function ( $description, $specific_id, $general_id ) {
global $post, $gpf_original_post;
$post = $gpf_original_post;
wp_reset_postdata();
return $description;
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment