Custom field to the listings
-
Hello,
I’m trying to add a custom field to the listings.
I’ve added the following code to have the fields in the backoffice:
add_filter( 'auto_listings_metabox_specs', function ( $fields ) { $prefix = '_al_listing_'; $fields[8] = array( 'name' => __( 'Co2 uitstoot (WLTP)', 'auto-listings' ), 'id' => $prefix . 'co2_uitstoot_wltp', 'type' => 'text', ); $fields[9] = array( 'name' => __( 'Co2 uitstoot (NEDC2.0)', 'auto-listings' ), 'id' => $prefix . 'co2_uitstoot_nedc', 'type' => 'text', ); return $fields; } );
This works so far.
Then I want to show it on the front end.
I added following code to the specifications.php :<tr> <th>Co2 Uitstoot NEDC</th> <td><?php get_post_meta( get_the_ID(), '_al_listing_co2_uitstoot_nedc', true) ?></td> </tr> <tr> <th>Co2 Uitstoot WLTP</th> <td><?php get_post_meta( get_the_ID(), 'co2_uitstoot_wltp', true) ?></td> </tr>
But the code doesn’t get picked up and get a blanc field.
To get the value of this custom field it is simply a matter of using get_post_meta( get_the_ID(), '_al_listing_custom_field', true) somewhere within the listing template.
The only thing I need to change is the
'_al_listing_custom_field'
to show the proper fields?Thanks for the help!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom field to the listings’ is closed to new replies.