How to get the ability to change the author of a post
Are you sure you have enabled Author from Screen Options in Post area? You can check the screenshot attached below for more info.
Are you sure you have enabled Author from Screen Options in Post area? You can check the screenshot attached below for more info.
I believe changing the following conditional: if( !current_user_can( ‘manage_options’ ) ) to this one: if( !current_user_can( ‘manage_options’ ) && ‘product’ === $query->get( ‘post_type’ ) ) would do it. Brief explanation: I added a second condition which checks if the query is for WooCommerce products where the post type is product. UPDATE If you want to … Read more
First, the author parameter is parsed and appended to the author__in and author__not_in query parameters. Then author__in or author__not_in array is processed. These can be arrays created from author parameter or arrays passed as query parameteres author__in / author__not_in or created from a mergion author parameter with author__in / author__not_in parameters. Parameters author__in and author__not_in … Read more
@CynthiaLara I suppose that you are using a container of WP_USER_QUERY::__construct in the form or WP_USER_QUERY or get_users or something to that effect. You can use ‘meta_key’ => ‘<YOUR_DESIGNATION_META_KEY>’,’orderby’ => ‘meta_value_num, to get results sorted by your meta key’s value. If you have used a texted based value in for this meta_key, please consider using … Read more
The code isn’t working because you haven’t defined or retrieved the $current_user or $post variables from anyway. You’ve also got a ! here for some reason: !$current_user->ID, which will just break the condition. You need to use the appropriate functions to get their values, and also use is_single() to make sure you’re viewing a single … Read more
exclude specific authors from WP_Query You can do it like so: $args = array( ‘author__not_in’ => array( 10, 3, 4 ), ); $posts_query = new WP_Query( $args ); But if you meant “from WP_User_Query“, then in WP_User_Query, you should use the exclude parameter, and that array(‘who’ => ‘authors’) shouldn’t be in meta_query: $args = array( … Read more
Yes, you can do it pretty easily using get_the_author_meta function and post_class filter: function add_author_nicename_to_post_class( $classes, $class, $post_id ) { $classes[] = get_the_author_meta( ‘user_nicename’ ); return $classes; } add_filter( ‘post_class’, ‘add_author_nicename_to_post_class’, 10, 3 );
all you have to do is to add an param: /* user commnet count */ function get_comment_count( $user_ID ) { global $wpdb; $count = $wpdb->get_var( $wpdb->prepare( “SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE user_id = %d “, $user_ID ) ); return $count; } <?php echo get_comment_count( <USER_ID> ); ?> PS. I’ve added some proper escaping in your … Read more
From codex: is_author() is a conditional tag which determines whether the query is for an existing author archive page. so it does not work for your scope. Best solution, instead of using the template file header.php is to write a function in functions.php hooking the proper action wp_head: add_action(‘wp_head’,’AS_exclude_author_from_indexing’); function AS_exclude_author_from_indexing(){ $toIndex = array(111,112,113); $user_id … Read more
This is untested, but you could use the wp_insert_post_data filter to change the post author to a specific value whenever a post is inserted or updated: add_filter( ‘wp_insert_post_data’, function( $data ) { if ( ‘post’ === $data[‘post_type’] ) { $data[‘post_author’] = 2; // Replace with desired author’s user ID. } return $data; } ); Just … Read more