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

    (@gwin)

    Hi,
    you can prefill the title field using adverts_form_bind filter, the code below will do that you can add it in your theme functions.php file

    
    add_filter( "adverts_form_bind", "my_adverts_form_bind", 1000 );
    function my_adverts_form_bind( $form ) {
        try {
            if( $form->get_value( "post_title" ) ) {
                return $form;
            }
            $titles = array(
                "property-buyer" => "Default Buyer Title",
                "seller" => "Default Seller Title"
            );
            $key = adverts_request( "preselected_category" );
            if( $form->get_scheme( "name" ) == "advert" && isset( $titles[$key] ) ) {
                $form->set_value( "post_title", $titles[$key] );
            }
        } catch(Exception $e) {
            // do nothing
        }
        return $form;
    }
    

    Just change the “Default Buyer Title” and “Default Seller Title” to actual titles you would like to use.

    Thread Starter hammeri1

    (@hammeri1)

    Thanks Greg,

    If I want this to work for any theme would I be better off creating in a plugin?

    Cheers,

    Richard.

    Thread Starter hammeri1

    (@hammeri1)

    All done via plugin. Works a treat.

    Thanks for your super quick support as ever.

    Onwards!

    Richard.

    Thread Starter hammeri1

    (@hammeri1)

    Marking as resolved. Many thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Default Ad Title’ is closed to new replies.