Page, Post, and CPT ID in Admin columns

From time to time you need to set up a bunch of conditions with Oxygen Builder that requires Page or Posts ID numbers. To get them you need to open every page or post and find it under URL. Much easier is to get numbers directly inside Admin Columns so you don’t need to open them at all.

<?php

add_filter('manage_posts_columns', 'dplugins_posts_columns_id', 5);
add_action('manage_posts_custom_column', 'dplugins_posts_custom_id_columns', 5, 2);
add_filter('manage_pages_columns', 'dplugins_posts_columns_id', 5); // for pages
add_action('manage_pages_custom_column', 'dplugins_posts_custom_id_columns', 5, 2); // for pages
 
function dplugins_posts_columns_id($defaults){
    $defaults['wps_post_id'] = __('ID');
    return $defaults;
}
function dplugins_posts_custom_id_columns($column_name, $id){
    if($column_name === 'wps_post_id'){
            echo $id;
    }
}

?>

Scripts Organizer Settings

Trigger Location: Everywhere
Script Location: PHP

screenshot 2021 04 15 at 21.29.12 1

// newsletter

Three tested WordPress snippets a week

Blocks, security, performance, Tailwind, PHP and React. Copy, paste, ship. You’ll also get DPlugins product updates. No spam, and you can unsubscribe anytime.

// newsletter

Three tested WordPress snippets a week

Blocks, security, performance, Tailwind, PHP and React. Copy, paste, ship. You'll also get DPlugins product updates. No spam, and you can unsubscribe anytime.

Click to Copy