Attaching author tag to the comment
you can compare user_id to the author id, an then add your text. global $post; if ( $comment->user_id === $post->post_author ) { echo ‘Author’; }
you can compare user_id to the author id, an then add your text. global $post; if ( $comment->user_id === $post->post_author ) { echo ‘Author’; }
You can use add_permastruct() (with ep_mask set to EP_AUTHORS) to add the proper rewrite rules, and the author_link filter to set the proper author URL: add_action( ‘init’, function(){ add_permastruct( ‘%author_trip_vendor%’, ‘operator/%author%’, [ ‘ep_mask’ => EP_AUTHORS, ] ); } ); add_filter( ‘author_link’, function( $link, $author_id, $author_nicename ){ if ( user_can( $author_id, ‘trip_vendor’ ) ) { $link … Read more
You probably need to add 3 capabilities: edit_published_posts publish_posts delete_published_posts but at the very least, you need to add publish_posts as that is the capability WordPress uses to determine what users are shown in Authors drop-down. Note: Changing capabilities is stored in the database so the recommendation is to modify these values via a plugin … Read more
<!–?php the_author(); ?–> is an HTML comment. Means it won’t fire the PHP inside it. As you already found out it should be <?php the_author(); ?> when placed in an PHP template file inside a so called The Loop. Which you are already doing right. Now there’s WordPress’ Template Hierarchy. Means you need to place … Read more
Not sure if you’re looking for an “automated” way of doing this, but in code you can get an array of all co-authors by using $authors = get_coauthors();. Once you have your authors array, you can loop through it and use each author object’s ID to get posts by that author: $authors = get_coauthors(); foreach … Read more
You’re almost there. Here’s the part that is setting the author of post to user with ID = 1: ‘post_author’ => 1, ‘post_status’ => ‘publish’, ‘post_type’ => ‘testimonial’, ‘author’ => $current_user->ID, You even try to set the author to $current_user, but you don’t initiate this variable anywhere in your code and you set author field … Read more
get_author_posts_url() doesn’t return the author URL, because of wrong author_structure
To get author role in single.php you have to get author id first. Use following code to get author id $author_id = get_the_author_meta( ‘ID’ ); Then get userdata using $user = get_user_by( ‘ID’, $author_id); or you can use $user = get_userdata( $author_id ); now you can display role of author using : echo implode(‘, ‘, … Read more
An URL-friendly version of your username (login) will be part of the url (slug/nicename) to your author archive page, unless your email is equal to your username. You can change this by a plugin like WP Author Slug. Then make sure your display name, as found on your profile page, is something you want people … Read more
And add the username to the array https://codex.wordpress.org/Function_Reference/get_pages <?php $args = array( ‘sort_order’ => ‘asc’, ‘sort_column’ => ‘post_title’, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ => ”, ‘meta_key’ => ”, ‘meta_value’ => ”, ‘authors’ => ”, ‘child_of’ => 0, ‘parent’ => -1, ‘exclude_tree’ => ”, ‘number’ => ”, ‘offset’ => 0, ‘post_type’ => ‘page’, ‘post_status’ … Read more