How to sort a non-meta field in the User Admin Panel?

The WP_User_Query::parse_orderby() actually supports sorting by the number of posts, but because WP_User_Query::parse_orderby() limits by what users can be sorted, accomplishing a custom sort is a bit of a hack. Here’s the workaround I’ve created (semi-tested): add_filter( ‘manage_users_sortable_columns’, static function ( $columns ) { $columns[‘articles_count’] = array( ‘articles_count’, false, __( ‘Articles’ ), __( ‘Table ordered … Read more

Default Editor – columns not printing [closed]

The columns appear vertically because when printing, the viewport is considered quite narrow. For the column blocks to appear horizontally next to each other, they have this in the CSS for the core/columns block: @media (min-width:782px) { .wp-block-columns { flex-wrap:nowrap!important } } This media query does not pass when printing, thus the columns appear vertically. … Read more

column values not showing after merging two custom post types

The correct action hook for printing custom column content is manage_loads_posts_custom_column, not manage_invoices_posts_custom_column (tested). This is because the row is itself for a loads post type, and not an invoices post type. Because you’re on the page for invoices, the filter to add columns works with invoices. Tested: add_action( ‘manage_loads_posts_custom_column’, ‘invoice_custom_column’, 10, 2 ); I … Read more

Sorting Users page admin column with ACF field

You can use the “pre_user_query” filter hook to modify the query that retrieves the users. Here’s an example code that how to sort the Users page admin column with an ACF field named. function sort_users_by_acf_field( $query ) { if ( ! is_admin() ) { return; } if ( isset( $query->query_vars[‘orderby’] ) && ‘user_company_name’ === $query->query_vars[‘orderby’] … Read more

Last Logged In Sortable Column

The default Last Login column only applies to users who are currently logged in. The timestamp is deleted when the user logs out. First, you need to save the timestamp when a user logs in. This will save it to user_meta. function save_login_timestamp( $user_login, $user ) { update_user_meta( $user->ID, ‘last_login’, time() ); } add_action( ‘wp_login’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)