Search for Resources and Solutions

How to add a dropdown option in the Frontend's settings

In the previous article i've written about how to create a new page in the Frontend's Settings page. At this moment is not possible to import settings in an existing pages. The options aren't added as array like for User's panel. I have some reason to add this in a different way.

I've created special Inc files which generates HTML code for dropdowns, inputs, textarea, image select, etc. These Inc files ca be called with a simple php function.

For dropdown, you have to use the function get_option_dropdown:

get_option_dropdown(

    'an unique slug',

    array(

        'search' => true, // Could be true or false

        'words' => array(

            'select_btn' => 'Text for dropdown's button by default',

            'search_text' => 'Text for input's placeholder if the search is enabled.',

        )

    )

);

Please don't use the option wherever you want. In the Frontend's Settings pages will be supported well. For other components i will write in the Development's category.

The selected options will be saved in the options table from the database.

Was this article helpful?