• Resolved chris29888

    (@chris29888)


    Parts of this have been asked before, but I can’t get the suggested solutions to work.
    I want to add custom fields for the details and specifications categories of my listings.
    I managed to add a custom detail field by adding the following two filters to my functions.php:

    add_filter( 'auto_listings_metabox_details', function ( $fields ) {
        $prefix = '_al_listing_';
        $fields[3] = array(
            'name' => __( 'Test-Detail', 'auto-listings' ),
            'desc' => __( 'A custom description', 'auto-listings' ),
            'id' => $prefix . 'test-detail',
            'type' => 'text',
        );
        return $fields;
    } );
    
    add_filter( 'auto_listings_details_array', function( $fields ) {
    	$fields[ 'Test-Detail' ] = auto_listings_meta( 'test-detail' );
    	return $fields;
    } );

    But when I try to add custom specifications, it only shows up in the backend. The frontend doesn’t display the value I entered.
    Here’s the code I’m using to generate the custom spec:

    add_filter( 'auto_listings_metabox_specs', function ( $fields ) {
        $prefix = '_al_listing_';
        $fields[3] = array(
            'name' => __( 'Test-Spezifikation', 'auto-listings' ),
            'desc' => __( 'A custom description', 'auto-listings' ),
            'id' => $prefix . 'test-spezifikation',
            'type' => 'text',
        );
        return $fields;
    } );
    
    add_filter( 'auto_listings_spec_fields', function( $fields ) {
    	$fields[ 'Test-Spezifikation' ] = auto_listings_meta( 'test-spezifikation' );
    	return $fields;
    } );

    There’s probably an error in the first filter as that’s the one I tried to reverse-engineer from the previous “details” filter.

    And how would I go about adding my own tabs? I need to sort the available specs into smaller sub-categories instead of listing everything under “details” and “specifications”.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding fields and tabs’ is closed to new replies.