Zi 字媒體
2017-07-25T20:27:27+00:00
目錄
原始文章
WooCommerce-在後台訂單編輯頁面新增上一筆/下一筆 快速切換按鈕
//----- ↓ 上一筆 / 下一筆訂單 Previous Order / Next Order ↓ -----//
add_action('woocommerce_order_actions_end','jump_to_previous_and_next_order');
function jump_to_previous_and_next_order($order_id) {
global $post, $wpdb;
$order_navigation = $wpdb->get_row( $wpdb->prepare( "
SELECT
(SELECT ID FROM {$wpdb->prefix}posts
WHERE ID < %d
AND post_type = '%s'
AND post_status <> 'trash'
ORDER BY ID DESC LIMIT 1 )
AS prev_order_id,
(SELECT ID FROM {$wpdb->prefix}posts
WHERE ID > %d
AND post_type = '%s'
AND post_status <> 'trash'
ORDER BY ID ASC LIMIT 1 )
AS next_order_id
", $post->ID, $post->post_type, $post->ID, $post->post_type ), ARRAY_A ); ?>
寫了
5860316篇文章,獲得
23313次喜歡