• Resolved bmontgomery

    (@bmontgomery)


    Hello,

    I’d like to know if it’s possible to remove the category field ?
    I don’t need this field for my ads.
    Could you please tell me how I can do ?
    If I remove it from the template, will it be enough ?
    Thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    You can do that by adding the code below in your theme functions.php file it will do that

    
    function customize_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "advert_category" ) {
            unset( $form["field"][$key] );
        }
      }
      return $form;
    }
    
    Thread Starter bmontgomery

    (@bmontgomery)

    Thanks.
    Are you sure there’s nothing missing ?
    You’re just declaring the function here.
    Where is it called ?
    I added this declaration in my functions.php file and nothing changed…

    Thread Starter bmontgomery

    (@bmontgomery)

    Finally I edited the function that adds my custom fields.
    I just added the “unset” part:

    
    function custom_adverts_form_load( $form ) {
    
        if( $form["name"] != "advert" ) {
            return $form;
        }
    
        // Here I add my custom fields
        // ...
    
        // removing category
        foreach( $form["field"] as $key => $field ) {
            if( $field["name"] == "advert_category" ) {
                unset( $form["field"][$key] );
            }
        }
    
        return $form;
    }
    add_filter( "adverts_form_load", "custom_adverts_form_load" );
    

    And it’s working fine.

    Another quick question:
    can I switch the order of the fields ?
    I’d like to have the image gallery after the ad description.
    Is it possible ?

    Plugin Author Greg Winiarski

    (@gwin)

    
        ...
        foreach( $form["field"] as $key => $field ) {
            if( $field["name"] == "gallery" ) {
                $form["field"][$key]["order"] = 10;
            }
        }
        ...
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘remove category field’ is closed to new replies.