I am now trying to figure out how to create the functions/ loops to pull my data from custom post types.

I have two post types(keys): And I need to pull the data from both to run my functions.

pods_product_grps: (p_high, p_med, p_low, m_type, group_id)

product_variant: (cogs, area, img_min, img_max, product_sku, grp_id)

Post are connected in 1 to many relationship where group_id==grp_id

So when displaying both the archive of pods_product_grps and the single post that has a subloop of each product_variant I need to display the calculated price based on a function I created.

The archive post only displays the lowest calculated price of the child variants.

Right now in my function, I have dummy variables to calculate the final price, but I need those to be populated automatically.

So I think I need to use this function:

get_post_meta(get_the_ID(),$key, true);

but do I need to run that function for each key I need to define, or is there a way to make the key value an array and then return the values as individual variables.

//used in calculations-- dummy data
$p_high= 3.2; //get_post_meta(get_the_ID(),$key, true);
$p_med= 1.3;
$p_low =1.1;
$cogs= 11.53;
$img_count =3; //number of selected images between $img_min and $img_max
$img_cost= 10; //defined in settings page
$area= 40;
$client_lvl; //defined in user meta

//used in product display

I am not including the price calculation here, but it is in my other questions, and I can post it if needed.

I am assuming that after my function, I would then create an action hook for it to display in the content.

Would these variables extractions need to happen within the actual loop of say (single-pods_product_grps.php) or would including them in the function itself work and then call via the action?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.