How to ‘If Author’ Comments Check

If you use the comment_class function to add classes to each comment, comments by the post’s author can be styled via the bypostauthor class. You can alternately match the comment ID against the post ID: global $post; if( $comment->user_id === $post->post_author ) { // is author comment }

Shortcut to widget/sidebar editing on the admin menu?

I think that using standard WP featurs there’s no shortcut. But you can workaround using a custom widget. As example create a very simple widget, something like: class MyPageWidget extends WP_Widget { function __construct() { parent::__construct( ‘MyPageWidget’, ‘My Page Widget’ ); } function widget( $args ) { $page = get_page_by_path(‘sidebar-page’); if ( ! empty($page) ) … Read more

How to change the default orderby from “Date” to e.g. “Title” or my custom column in content type records list in admin?

pre_get_posts the right hook you need to use. function CPT_set_default_orderby($q){ global $pagenow, $typenow; if( is_admin() && ‘edit.php’ == $pagenow && ‘post’ == $typenow && !isset($_GET[‘orderby’]) ){ // to order by title $q->set(‘orderby’, ‘title’); // to orderby with meta key $q->set(‘orderby’, ‘meta_key’); $q->set(‘meta_key’, ‘expiration’); } } add_action(‘pre_get_posts’, ‘CPT_set_default_orderby’);

disable trashability for certain pages

Add this to your functions.php in your theme folder: function restrict_post_deletion($post_ID){ $user = get_current_user_id(); $restricted_users = array(21,25,54,2,19); $restricted_pages = array(2,21,52,64); if(in_array($user, $restricted_users) && in_array($post_ID, $restricted_pages)){ echo “You are not authorized to delete this page.”; exit; } } add_action(‘wp_trash_post’, ‘restrict_post_deletion’, 10, 1); add_action(‘wp_delete_post’, ‘restrict_post_deletion’, 10, 1); Taken from here and updated to the latest WP version.

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