Display Meta Data in frontend
-
Hi there,
I’m trying to display meta data named company in the front end of the site. The above meta field is created usingadd_filter( 'wpsl_meta_box_fields', 'custom_meta_box_fields' ); function custom_meta_box_fields( $meta_fields ) { $meta_fields[__( 'Additional Information', 'wpsl' )] = array( 'company' => array( 'label' => __( 'company', 'wpsl' ) ) ); return $meta_fields; }
then I used this code in function.php
add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' ); function custom_frontend_meta_fields( $store_fields ) { $store_fields['wpsl_company'] = array( 'name' => 'company' ); return $store_fields; }
then I tried to show the company name in frontend using bellow code
add_filter( 'wpsl_listing_template', 'custom_listing_template' ); function custom_listing_template() { global $wpsl, $wpsl_settings; $listing_template = '<h5 class="Name"><%= company %></h5>' . "\r\n"; return $listing_template; }
After all the above steps, Search results do not appear as expected. Instead of results console error came in as company is not defined
Error https://prnt.sc/6ZkLcgzw7a1M
Result Page: https://prnt.sc/nvlxmG_K4Haa
I have followed this article and this page
Thank you
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Display Meta Data in frontend’ is closed to new replies.