// Unhide it items[xxxItemIndex].hidden = false;
// Move to top: Update the post date to current time wp_update_post(array( 'ID' => $post_id, 'post_date' => current_time('mysql'), 'post_date_gmt' => current_time('mysql', 1) ));
// Force unhide and move to top function wp_move_xxx_to_top() { $post_id = 123; // Replace with your 'XXX' ID // Unhide: Change status from 'draft' to 'publish' wp_update_post(array( 'ID' => $post_id, 'post_status' => 'publish' ));
-- Step 1: Unhide the 'XXX' item UPDATE items SET status = 'visible' WHERE name = 'XXX' AND status = 'hidden'; -- Step 2: Move it to the top by setting its priority higher than all others -- First, make space by incrementing all other priorities (optional but effective) UPDATE items SET priority = priority + 1 WHERE status = 'visible' AND name != 'XXX';
// The dataset: array of objects let items = [ { id: 1, name: "AAA", hidden: false }, { id: 2, name: "XXX", hidden: true }, { id: 3, name: "BBB", hidden: false } ]; // Execute: xxx hinde move top function moveXXXToTop() { // Find the XXX item const xxxItemIndex = items.findIndex(item => item.name === "XXX"); if (xxxItemIndex === -1) return;
// Clear cache clean_post_cache($post_id); } add_action('init', 'wp_move_xxx_to_top'); For a dynamic web list where items can be visibly "hidden" via CSS class .hidden :
Take item with name = 'XXX' that is currently status = 'hidden' , unhide it, and set its priority to the maximum (highest position).
-- Step 3: Set the target item's priority to 0 (top) UPDATE items SET priority = 0 WHERE name = 'XXX';