Hi All,

I want to select specific drop down option to a selected post, for example the post is on Honda Fit, the the Drop Down should select Honda Fit automatically. The below code works fine but shows all posts instead of selecting specific to a post, e.g.

 select guid from wp_posts where guid='$_GET['guid'] and post_type='product'

, I know it in a query logic but when i implement the query, the metabox just keeps loading and does nothing.

Code responsible for fetching the drop down list:

automotive_admin_help_message(__("This setting allows you to associate a WooCommerce product with a listing and show an Add to Cart section to allow users to checkout and purchase items.", "listings")); ?>
        <div class="tab_content">
            <div>
                <?php                                                                                                                               
                $current_woo_id = get_post_meta($post->ID, "woocommerce_integration_id", true);
                $args = array(
                    'post_type'      => 'product',
                    'posts_per_page' => - 1                                         
                );
                $loop = get_posts( $args );
                if ( ! empty( $loop ) ) {
                    echo "<select name='woocommerce_integration_id' class='chosen-dropdown' style='width: 300px;'>";
                    echo "<option value=''>" . __( "No product association", "listings" ) . "</option>";
                    foreach ( $loop as $product ) {
                        $current_id = $product->ID;
                        echo "<option value='" . $current_id . "'" . selected( $current_id, $current_woo_id, false ) . ">" . $product->post_title . "</option>";
                    }
                    echo "</select>";
                } else {
                    echo __( 'No products found', 'listings' );
                }
                wp_reset_query();
                ?>
            </div>
        </div>
    </div>
    <?php } ?>

This is an image showing the all posts are being fetched Click Here
What I need is the drop down to select specific to that post Click Here

Thanks for your help in advance