pre_get_posts Tax Query not working for custom author page

Don’t run a new query in the template, modify the main query before it’s run via the pre_get_posts action in the theme’s functions.php file. function wpd_author_query( $query ) { if ( $query->is_author() && $query->is_main_query() ) { // your code to set $current_user_name here $query->set( ‘meta_key’, ‘_writer_relation_added_date_’ . $current_user_name ); $query->set( ‘orderby’, ‘meta_value_num’ ); $tax_query = … Read more

Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author

You will want to implement that using AJAX. Read these two articles from the Codex for further information about integrating WordPress with some AJAX action: AJAX AJAX in Plugins Just to give you a head start, you will want something like this: Client-side (Javascript) $(element).click(function() { var data = { action: ‘get_author_info’, author_id: your-author-id }; … Read more

Get the terms of a custom taxonomy for a specific author in author template

First get a list of the author posts then loop over the each post and get the terms used ex: function list_author_used_terms($author_id){ // get the author’s posts $posts = get_posts( array(‘post_type’ => ‘custom_post_type_name’, ‘posts_per_page’ => -1, ‘author’ => $author_id) ); $author_terms = array(); //loop over the posts and collect the terms foreach ($posts as $p) … Read more

How to display user role

Change: $user_roles = $current_user->roles; with $user = new WP_User( $user_id ); $user_roles = $user->roles; and the $user_id should e the actual user id who’s role you are trying to get. Update, Sorry i just read the author template part so try this: //first get the current author whos page you are viewing if(isset($_GET[‘author_name’])) $curauth = … Read more

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