Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Eyal Fitoussi

    (@ninjew)

    Hello @zohrabt,

    Try this function. Add it to the functions.php file of your theme:

    
    function gmw_add_price_custom_field_to_results( $gmw, $post ) {
    
    	$price = get_post_meta( $post->ID, '_regular_price', true );
    
    	if ( $price ) {
    		echo 'Price: ' . $price;
    	}
    }
    add_action( 'gmw_posts_loop_before_get_directions', 'gmw_add_price_custom_field_to_results', 50, 2 );
    

    I hope this helps.

    Thread Starter zohrabt

    (@zohrabt)

    Thank you. That worked for products.
    Do you know how I can add it for classified listings as well?
    Here is the link: https://www.zoneyx.com/classifieds/

    Thread Starter zohrabt

    (@zohrabt)

    Are there any updates or suggestions on this?

    Plugin Author Eyal Fitoussi

    (@ninjew)

    Hello @zohrabt,

    You should be able to display the price of classifieds using the same function above, but the custom field would be different.

    Unfortunately, I don’t know which custom field the classifieds plugin is using for price, so you will need to contact the classifieds plugin’s developers and ask them that.

    Once you have the custom field that you need, use this function below and replace the ‘custom_field_name’ with the actual custom field of the price:

    
    function gmw_add_classified_price_to_results( $gmw, $post ) {
    
    	$price = get_post_meta( $post->ID, 'custom_field_name', true );
    
    	if ( $price ) {
    		echo 'Price: ' . $price;
    	}
    }
    add_action( 'gmw_posts_loop_before_get_directions', 'gmw_add_classified_price_to_results', 50, 2 );
    

    I hope this helps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Price not showing in search results’ is closed to new replies.