Woocommerce

时间:2018-09-17 13:17:17

标签: wordpress

我想为选定的帖子选择特定的下拉选项,例如帖子在Honda Fit上,则Drop Down会自动选择Honda Fit。下面的代码工作正常,但显示所有帖子,而不是选择特定于帖子的内容,例如select guid from wp_posts where guid='$_GET['guid'] and post_type='product',我在查询逻辑中知道它,但是当我实现查询时,元框只会继续加载,什么也没做。

                     automotive_admin_help_message(__(“此设置可让您将WooCommerce产品与列表相关联,并显示“添加到购物车”部分,以允许用户签出和购买商品。”,“列表”))); ?>
        <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 } ?>

这是一张图片,显示所有帖子都已获取all posts image

我需要的是针对该帖子this is what i need it to be

进行选择的下拉菜单

非常感谢您的帮助

0 个答案:

没有答案