Add a custom field
-
Hi. I use this code (take it on https://wpadverts.com/documentation/custom-fields/) in a snippet to add some custom fields
add_filter( “adverts_form_load”, “my_adverts_form_load” );
function my_adverts_form_load( $form ) {
if( $form[“name”] != “advert” ) {
return $form;
}//Field 1
$form[“field”][] = array(
“name” => “my_custom_field”,
“type” => “adverts_field_text”,
“order” => 9,
“label” => “Autre Catégorie”,
“is_required” => false,
// “validator” => array( ),
);//Field 2
$form[“field”][] = array(
“name” => “my_custom_radio”,
“type” => “adverts_field_select”,
“order” => 10,
“label” => “Type d’annonce”,
“is_required” => false,
“validator” => array( ),
“max_choices” => 1,
“options” => array(
array(“value”=>”Vente”, “text”=>”Vente”),
array(“value”=>”Location”, “text”=>”Location”),
array(“value”=>”Echange”, “text”=>”Echange”),
),
“empty_option” => true,
“empty_option_text” => “Choisir l’opération”,
“meta” => array(
“search_group” => “visible”,
“search_type” => “full”
)
);return $form;
//Field 3
$form[“field”][] = array(
“name” => “my_custom_checkbox”,
“type” => “adverts_field_radio”,
“order” => 25,
“label” => “Etat”,
“is_required” => false,
“validator” => array( ),
“max_choices” => 1,
“options” => array(
array(“value”=>”Neuf”, “text”=>”Neuf”),
array(“value”=>”Occasion”, “text”=>”Occasion”),
)
);return $form;
}The fields 1 & 2 are added, no problem. But the field 3 is not add to my advert_add form. I also add the code to Displaying Custom Field in wp-admin List and Displaying on Ad Details Page. Same problem with field 3.
The topic ‘Add a custom field’ is closed to new replies.