Forums Forums Search & Filter Pro return product data on custom results.php page

Viewing 8 posts - 1 through 8 (of 8 total)
  • Anonymous
    #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
    #180781

    You 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
    #180876

    Hi 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
    #180880

    I 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
    #180884

    Sorry…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?

    Trevor
    #180886
    This reply has been marked as private.
    Trevor
    #180888
    echo get_post_meta( get_the_ID(), '_regular_price', true );
    
    Trevor
    #180890

    Great to speak with you. That code seems to have sorted it.

Viewing 8 posts - 1 through 8 (of 8 total)