Go to

Categories overview

Data Sources – Callback Function

If you do not know what are data sources in the WPAdverts Custom Fields extension please refer to the Getting Started with Data Sources article that will explain what are data sources and why you should use them.

Using Callback Function data source is the most complicated since it requires some PHP programming knowledge, so this is an option for programmers and developers mainly. If you do not feel confident programming your own PHP function consider using Predefined Options or Taxonomy data sources since they can handle most of the user cases anyway.

Registering ‘Callback’ Data Source

The callback function you can create and register in your theme or child-theme functions.php file or even better create a new blank WP plugin and add it there.

An example callback function you can register with the code below

add_action( "init", "register_data_source" );
function register_data_source( ) {
        "name" => "unique-name-here",            // some unique name of your choosing
        "title" => "Options",                    // this will be visible to users 
        "callback" => "data_source_function"     // function which will list options
function data_source_function( ) {
    return array(
            "value" => "apple",
            "text" => "Apple",
            "depth" => 0,
            "value" => "banana",
            "text" => "Banana",
            "depth" => 0,
            "value" => "orange",
            "text" => "Orange",
            "depth" => 0,

Using ‘Callback’ Data Source

Once you have your callback function and a data source registered you can use it from wp-admin / Classifieds / Options / Custom Fields panel while

Go to wp-admin / Classifieds / Options / Custom Fields / Form Schemes panel, create a new form or edit existing one.

Edit one of the fields that can use Data Source (that is Checkbox, Radio, and Select) in “Fill Method” select “Use registered data source“, a new field named “Data Source” will load, select in it the data source you created and save the field.

Was this article helpful?