Hi, you can hide the price and location fields by adding the code below in your theme functions.php file.
add_filter( "adverts_form_load", "customize_adverts_add" );
function customize_adverts_add( $form ) {
if( $form['name'] != "advert" ) {
return $form;
}
foreach( $form["field"] as $key => $field ) {
if( $field["name"] == "adverts_price" || $field["name"] == "adverts_location" ) {
unset( $form["field"][$key] );
}
}
return $form;
}
Thread Starter
mrblues
(@mrblues-1)
I use plugin called Snippets to add these piece of codes and when I add your codes I get this error message.
Don’t Panic
The code snippet you are trying to save produced a fatal error on line 12:
Cannot redeclare customize_adverts_add() (previously declared in /home/inno/public/html/sivut/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()’d code:2)
The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.
Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.
what this means ?
Seems you are already using customize_adverts_add function, you will need to change the function name, to do that instead of the previous code use the one below instead.
add_filter( "adverts_form_load", "mrblues_customize_adverts_add" );
function mrblues_customize_adverts_add( $form ) {
if( $form['name'] != "advert" ) {
return $form;
}
foreach( $form["field"] as $key => $field ) {
if( $field["name"] == "adverts_price" || $field["name"] == "adverts_location" ) {
unset( $form["field"][$key] );
}
}
return $form;
}
Thread Starter
mrblues
(@mrblues-1)
this is working, many thanks and cheers! 🙂