I am using Aqua page builder and I want to incorporate dropdown catagory select field for that.

$my_options = array ('one' => 'My Pony','two' => 'His Pony');
echo aq_field_select('categories', $block_id, $my_options, $categories);

I have tried $my_options= get_categories(); But it does not work. The function was basically

    function aq_field_select($field_id, $block_id, $options, $selected) {
    $options = is_array($options) ? $options : array();
    $output = '<select id="'. $block_id .'_'.$field_id.'" name="aq_blocks['.$block_id.']['.$field_id.']">';
    foreach($options as $key=>$value) {
        $output .= '<option value="'.$key.'" '.selected( $selected, $key, false ).'>'.htmlspecialchars($value).'</option>';
    $output .= '</select>';

    return $output;

Thank you .


I think this is what you are looking for .

$cats = get_terms('category');
$blog_cats = array("all" => "All");
foreach ($cats as $cat) {
$blog_cats[$cat->name] = $cat->name;}

Then to show this

<?php echo aq_field_select('category', $block_id, $blog_cats, $category); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.