Add Post Author body class to WordPress

$author = $wp_query->post->post_author; $author = get_user_by(‘id’, $author); author->user_nicename; That should get you the author slug which you can use in your conditional statement. get_the_author can only be used inside the loop.

If statement for is_author of a post

You can access the posts author (inside the loop) with the global $post; echo $post->post_author If your sidebar comes after your main content (in code), then you could populate a global array (not the best solution, but ok). // in the loop: Add each author to the global $post_authors array $post_authors[] = $GLOBALS[‘post’]->post_author; // in … Read more

Author page points to 404 error page

The user_nicename should never have spaces. It is a sanitized version of user_name, that has been sanitized (Aa-Zz,0-9,_,-) to be suitable for use as a slug. If you have spaces in your user_nicename values, you’re going to get 404 errors. To correct, you’ll probably need to edit the database directly. Here are instructions, with screenshots, … Read more

post author if statement

The get_posts() function retrieves posts from the database. If I understand you correctly, that’s not what you want though, you simply mean to check the author of the post currently displayed. You can simply use $post->post_author. If outside the Loop, you have to call upon the $post global first. Hence global $post; // only required … Read more

Can’t change author to myself after post published

I guess you need administrator permissions to change the authors or modify the user role permissions. WordPress allows changing the post author only to a super-admin or a user with the right to edit others posts. Also, an editor only has these permissions

Display all authors in a theme template

What you need here is to shuffle all the array elements & then display them. But since php’s shuffle() function doesn’t preserve array key associations, here’s a version that does. function shuffle_assoc(&$array) { $keys = array_keys($array); shuffle($keys); foreach($keys as $key) { $new[(string)$key] = $array[$key]; } $array = $new; return true; } Add this function somewhere … Read more

How can I get all author written content?

Your question is not very detailed or very clear but get_user_meta will return all of the user metadata for a user. That should have all of your fields. You could also use get_users for the second tab. I am not dealing with the first since you state that your “have no idea how to do … Read more

How to show author page link

Have you tried something like: /*Get number of entries*/ function get_entries_num( $id ) { $count= count_user_posts( $id ); if ($count == 1) { return ‘<a href=”‘.get_author_posts_url($id).'”>’.sprintf(__(‘%s total post’,’upme’), $count).'</a>’; } else { return ‘<a href=”‘.get_author_posts_url($id).'”>’.sprintf(__(‘%s total posts’,’upme’), $count).'</a>’; } }

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