Support » Plugins » Can't get wp_dropdown_categories to work inside plugin

  • I managed to create an external page that shows a drop-down of all my categories inside my custom taxonomy called Frequencies that the user can select. The code is as simple as this (scrape.php):

    define( 'WP_USE_THEMES', false );
    require( '../wp-load.php' );
    // delete the above two lines when using as plugin
    <?php wp_dropdown_categories(array(
                                'child_of' => 0,
                                'class' => 'postform',
                                'depth' => 0,
                                'echo' => 1,
                                'exclude' => '',
                                'hide_empty' => false,
                                'hide_if_empty' => false,
                                'hierarchical' => true,
                                'id' => '',
                                'name' => 'cat-dropdown',
                                'order' => 'ASC',
                                'orderby' => 'name',
                                'selected' => 0,
                                'show_count' => 0,
                                'show_option_all' => '',
                                'show_option_none' => __('None'),
                                'tab_index' => 0,
                                'taxonomy' => 'frequency',
                            )); ?>

    The above displays the following options:


    Now, I want to CONVERT the above into doing the same thing, but within the context of a plugin. The idea is the plugin asks the user to select a category and press submit to go to an options page.

    So far I have created an admin.php page that contains the following:

    <?php include(plugin_dir_path(__FILE__).'scrape.php'); ?>

    So I have the plugin that displays a dropdown, but the dropdown only contains ONE option rather than displaying all the categories available under the taxonomy.

    The output it as follows:


    So the question is, what happens to the other 2 options?

  • The topic ‘Can't get wp_dropdown_categories to work inside plugin’ is closed to new replies.