skip to Main Content

I am fluent in HTML and CSS but not so much in PHP. Any help would be appreciated.

I have a custom function in WordPress as seen below:

function prefix_calculation_global_calculation_vars( $vars ) {
    return array(
        'setup_cost' => 200,
    );
}
add_filter( 'pewc_calculation_global_calculation_vars', 'prefix_calculation_global_calculation_vars' );

Is it possible to call an Advanced Custom Fields (ACF) field or a Pods field and have the value inserted into the function above where the 200 is?

2

Answers


  1. You would have to grab it via the $wpdb->postmeta table

    <?php echo get_post_meta(get_the_ID(), 'setup_cost', TRUE); ?>
    
    Login or Signup to reply.
  2. Providing get_the_ID() works you could try this:

    function prefix_calculation_global_calculation_vars( $vars ) {
        return array(
            'setup_cost' => get_field('setup_cost', get_the_ID()),
        );
    }
    add_filter( 'pewc_calculation_global_calculation_vars', 'prefix_calculation_global_calculation_vars' );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search