Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Created December 16, 2025 07:20
Show Gist options
  • Select an option

  • Save marklchaves/e6acaf5fbbfac9279e0c17ad416b4352 to your computer and use it in GitHub Desktop.

Select an option

Save marklchaves/e6acaf5fbbfac9279e0c17ad416b4352 to your computer and use it in GitHub Desktop.
Custom PHP code that makes Popup Maker's Enabled column sortable
<?php
/**
* Make Popup Maker's Enabled column sortable
*/
// Add 'enabled' to sortable columns
add_filter( 'manage_edit-popup_sortable_columns', function( $columns ) {
$columns['enabled'] = 'enabled';
return $columns;
}, 20 );
// Handle the sorting logic for the enabled column
add_filter( 'request', function( $vars ) {
// Check if we're viewing the "popup" post type
if ( isset( $vars['post_type'] ) && 'popup' === $vars['post_type'] ) {
// Check if we're sorting by 'enabled'
if ( isset( $vars['orderby'] ) && 'enabled' === $vars['orderby'] ) {
$vars = array_merge(
$vars,
[
'meta_key' => 'enabled',
'orderby' => 'meta_value_num',
]
);
}
}
return $vars;
}, 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment