Gists

3 months ago
<?php
/** creates a dynamic tag for use in the facetwp layout builder - {{ cart }} **/

add_filter( 'facetwp_builder_dynamic_tag_value', function( $tag_value, $tag_name, $params ) {
    if ( 'cart' == $tag_name ) {
        global $product;
        $product = wc_get_product( get_the_ID() );
        ob_start();
        woocommerce_template_loop_add_to_cart();
        $tag_value = ob_get_clean();
    }
    return $tag_value;
  }, 10, 3 );
5 months ago
<?php

/** get a user acf field for the post author
 ** use as {{ acf:author_title }} in an HTML item in layout builder
 **/

add_filter( 'facetwp_builder_dynamic_tag_value', function( $tag_value, $tag_name, $params ) {
  if ( 'acf:author_title' == $tag_name ) {
      $author = get_post_field( 'post_author', $params['post']->ID );
      $tag_value = get_field( 'first_name', 'user_' . $author );
  }
  return $tag_value;
}, 10, 3 );