Filter Hook for post table (not columns)

The same way you would do it on the frontend, with pre_get_posts. Combine it with get_current_screen() so you can tell which area of the admin you’re in, and hook the filter on admin_init so it doesn’t impact the frontend. There’s also the restrict_manage_posts which will let you add inputs to the filter column: https://developer.wordpress.org/reference/hooks/restrict_manage_posts/ Just … Read more

How to get different Related Posts

Randomizing your tags doesn’t matter much to WP_Query. If you want random results, try adding ‘orderby’ => ‘rand’ to your $args. This should randomize the stories returned. If not, try applying shuffle() to $my_query before iterating through them. Some web hosts have reportedly disabled the ‘orderby’=>’rand’ method of querying posts. For these hosts shuffle() seems … Read more

Navigate through the posts using keyboard arrows

You’re using get_next_post and get_previous_post correctly with get_permalink. The next and prev functions either return a WP_Post object or a falsy value. The permalink function accepts either a post object or a valid post ID and returns the post url as string, if it was found, otherwise it returns boolean false. I tested the code … Read more

wp_posts table extremely large

Most of the space in that table in your case is taken by the overhead. 919MB is full size, with 885MB of overhead. Overhead is caused by the storage and index write operations in the MyISAM database engine storage. You can run this query to clear overhead: OPTIMIZE TABLE `wpwn_posts` Or, you can convert all … Read more

Move posts from a non-wordpress site to wordpress

If the previous posts are a service supported by WordPress’ importer you could try using that. https://wordpress.org/support/article/importing-content/ If that doesn’t support your previous blog service you could try WP All Import http://www.wpallimport.com/ I’ve used both of these methods with pretty good success.

Edit post locked notification dialog on edit post screen (post.php)… hook maybe?

I believe the easiest approach is to hide that Preview button via CSS. Here is a snippet or you can add that style to a pre-existing wp-admin stylesheet that you might have already included. add_action( ‘admin_head-post.php’, function(){ echo ‘<style>’; echo ‘.edit-post-header__settings .editor-post-preview { display: none !important; }’; echo ‘</style>’; }); I tried digging through the … Read more

Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop

This can be done using WP_Query using author and tax_query. Something like this: $args = array( ‘post_type’ => ‘post’, ‘author’ => get_current_user_id(), ‘tax_query’ => array( array( ‘taxonomy’ => ‘custom-taxonomy’, ‘operator’ => ‘EXISTS’ ), ), ); $query = new WP_Query( $args ); And then check if posts are returned through this query. Please note that this … Read more