ami_2 0 Newbie Poster

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">
                $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' );
    <?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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.