Custom loop for custom post type for current author

You can get the current user ID using $user_id = get_current_user_id(); and use the $user_id in your query. $user_id = get_current_user_id(); $loop = new WP_Query( array( ‘post_type’ => ‘html5-blank’, ‘category_name’ => ‘chapter’, ‘author’ => $user_id ) ); if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class=”pindex”> <div class=”ptitle”> <h2><?php echo … Read more

Custom Post type sort order not working in the admin area

The ‘title’ and ‘date’ columns are WordPress default tables (even for CPTs) so they should be automatically sortable, unless those columns have been replaced. For custom columns there is a hook for registering a column as ‘sortable’: https://developer.wordpress.org/reference/hooks/manage_this-screen-id_sortable_columns/ //Filter is ‘manage_edit-{custom post type}_sortable_columns //or more generally ‘manage_{screen id}_sortable_columns add_filter( ‘manage_edit-cpt_sortable_columns’, ‘wpse221267_cpt_sortable_columns’ ); function wpse221267_cpt_sortable_columns( $columns … Read more