• 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)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @nhalauxehoi I’ve deleted your offer to login to your user’s site. I’m am 100% sure you mean well but please never ask for credentials. I have flagged your account temporarily. That just means that your post will need to be approved and @ notifications from you will not work.

    https://wordpress.org/support/guidelines/#the-bad-stuff

    Now for the why: The internet is a wonderful place full of very nice people and a few very bad ones. I’m sure everyone here is very nice however, by giving some ones keys to your house you are trusting they wont steal anything. Likewise the person who takes the keys is now responsible for the house FOREVER.

    If something was to go wrong, then you the author may well legally become liable for damages, which they would not normally have been as their software is provided without warranty.

    Please be aware that repeatedly asking for credentials will result in us asking you to repeatedly stop before escalating up to the plugins team.

    Plugin Support Hung PD

    (@nhalauxehoi)

    Hi,

    @jdembowski Thank you for clarify.

    I will remember and advoid this in the feature.

    Regards,
    Hung PD

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom field to the listings’ is closed to new replies.