In the "form" method of one of my widgets I make a query to offer the user some posts to choose from, like this:

    $products = new WP_Query( array(
        'post_type'      => 'ys_product',
        'order'          => 'ASC',
        'orderby'        => 'title',
        'meta_query'     => array(
                'key'   => 'ys_product_status',
                'value' => 'ok',
        'posts_per_page' => - 1
    ) );

    if ( $products->have_posts() ) {
        while ( $products->have_posts() ) : $products->the_post();
            $product = array(
                'name' => the_title_attribute( array( 'echo' => FALSE ) ),
                'ID'   => get_the_ID(),

            $prod_array[] = $product;

For some reason, with that code there things go more or less wrong. The widget works, the wp_query populates the appropriate select, the widget displays and can be configured both through regular the Widgets page or the Customizer.


For some reason, while in the customizer this widget has the following css rule applied:

.customize-control-widget_form:not(.widget-rendered) {
  opacity. 0.5

Which of course in turn produces this: widget with opacity changed

Also, while in the customizer I can't use anymore the "add new widget" button unless I remove this widget (it gives an error in customizer.js, complaining that TypeError: control is undefined.

Everything seems to work, but obviously something is wrong because I'm breaking Customizer. Anyone has a clue what's going on here?

Update: I ended up replacing WP_Query with a an sql query through $wpdb, and now everything works as intended. Still, would like to know why it isn't working as it should written as it was. :(

Thanks and regards. (WP 4.1)


I was having the exact same problem while querying post and pages, but also the jetpack-portfolio post type in my custom widgets.

I was using $query = new WP_Query( $query_args ); in both cases. For me the fix was to change $query to $query_entries and $query_projects. It works as expected now.

I see you're already using $products, but maybe it conflicts with some other query you run. Try to change that and see if it does the trick.

UPDATE: Disregard that, it didn't fix it. If I close the Customizer and come back to it, the widgets are still acting weird.

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.