Skip to content

Instantly share code, notes, and snippets.

@tomusborne
Last active June 28, 2017 22:27

Revisions

  1. tomusborne revised this gist Jun 28, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    if ( strpos( $content, '{{custom_field' ) !== false ) {
    $data = preg_match_all('/{{custom_field="([^"]*)"}}/', $content, $matches);
    foreach ( $matches[1] as $match ) {
    if ( null !== get_post_meta( get_the_ID(), $match, true ) && '' !== get_post_meta( get_the_ID(), $match, true ) ) {
    if ( null !== get_post_meta( get_the_ID(), $match, true ) ) {
    $search[] = '{{custom_field="' . $match . '"}}';
    $replace[] = get_post_meta( get_the_ID(), $match, true );
    }
  2. tomusborne created this gist Jun 28, 2017.
    9 changes: 9 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    if ( strpos( $content, '{{custom_field' ) !== false ) {
    $data = preg_match_all('/{{custom_field="([^"]*)"}}/', $content, $matches);
    foreach ( $matches[1] as $match ) {
    if ( null !== get_post_meta( get_the_ID(), $match, true ) && '' !== get_post_meta( get_the_ID(), $match, true ) ) {
    $search[] = '{{custom_field="' . $match . '"}}';
    $replace[] = get_post_meta( get_the_ID(), $match, true );
    }
    }
    }