This content has been restricted to logged-in users only. Please log in to view this content.
function ch_orders_table_shortcode() {
// Query Orders CPT (change 'orders' to your real CPT slug)
$args = array(
'post_type' => 'orders',
'posts_per_page' => -1,
'author' => get_current_user_id() // only show the logged-in user's orders
);
$orders = get_posts($args);
if (!$orders) {
return "';
$output .= '
';
return $output;
}
add_shortcode('orders_table', 'ch_orders_table_shortcode');
No orders found.
"; } // Start table $output = '| Order ID | Buyer ID | Age | Quantity | Status | View |
|---|---|---|---|---|---|
| ' . $order->ID . ' | '; $output .= '' . esc_html($buyer_id) . ' | '; $output .= '' . esc_html($age) . ' | '; $output .= '' . esc_html($qty) . ' | '; $output .= '' . esc_html($status) . ' | '; $output .= 'View | '; $output .= '