Forums › Forums › Search & Filter Pro › return product data on custom results.php page
- This topic has 7 replies, 2 voices, and was last updated 6 years, 4 months ago by Trevor.
-
Anonymous(Private) June 20, 2018 at 11:19 am #180763
Hi I am having trouble getting any data other than the example fields to display in my search results
I would like to display product price, product attributes etc. on my custom results.php page.
I have previously done this using ACF eg. the_field(fieldname), but i çant find the syntax/ field names to reference for woocommerce.All my HTML is working, im just note sure what i should be referencing to return product specific data in the results.
Full disclaimer – not a PHP person
‘thank you
Trevor(Private) June 20, 2018 at 2:14 pm #180781You would need to use this function I think to get and display the data in the custom fields:
https://developer.wordpress.org/reference/functions/get_post_meta/
Anonymous(Private) June 20, 2018 at 10:54 pm #180876Hi there,
When i got the custom fields (ACF) to display on a previous project i did not need to use get_post_meta i thought that was what your plugin does! all i used was <?php the_field(fieldname); ?>
I am already returning some of the post data eg: <?php the_title(); ?> – i just need to get more of the data from the post in the search results. your reply doesn’t really clarify my issue.
Any further suggestions?
Trevor(Private) June 21, 2018 at 4:23 am #180880I had not realised you were using ACF this time round. You are correct, the_field() is one method you can use. Sometimes it also needs the post ID in there as the second argument. Maybe
<?php echo the_field('fieldname',get_the_ID());?>
Note, for ACF, the fieldname never starts with an underscore.
Anonymous(Private) June 21, 2018 at 4:57 am #180884Sorry…we are not communicating very well here!
I am not using ACF this time around. I was using this as an example of the code snippet i used to display the post data.
This time i am using woocommerce products. I can get generic post info to display (ID, post name etc) but not Woocommerce specific data. Such as the price.
Is there a syntax that is specific to woocommerce i am overlooking here?
-
AuthorPosts