Twenty Twelve Author not displaying
Go into your themes single.php file and put this code in a proper place under the the_title(); This Post was written by <?php the_author(); ?>
Go into your themes single.php file and put this code in a proper place under the the_title(); This Post was written by <?php the_author(); ?>
try this in functions.php function author_after_content($content) { if ( is_singular(‘post’) ) { $content .= “<p>بقلم : ” . the_author() . “</p>”; } return $content; } add_filter(‘the_content’, ‘author_after_content’, 20);
Use get_userdata() to retrieve all user data. The function accepts user ID. So the following code will give you the user url. <?php php $user_info = get_userdata(1); /* replace 1 with dynamic user id variable in your context*/ echo ‘User url: ‘ . $user_info->user_url . “\n”; echo ‘Users name: ‘ . $user_info->first_name . “\n”; ?>
The function you are using, get_most_recent_post_of_user, won’t work as it only retrieves the latest post from the author. It cannot retieve a list of posts Walks through each of a user’s blogs to find the post with the most recent post_date_gmt. You will most probably be better of using either WP_Query or get_posts to achieve … Read more
Query for post type listing_type and author ID within your loop: $args = array( ‘post_type’ => ‘listing_type’, ‘author’ => get_the_author_meta( ‘ID’ ) ); $listing_post = new WP_Query( $args ); if( $listing_post->have_posts() ){ while( $listing_post->have_posts() ){ $listing_post->the_post(); the_permalink(); } } // reset $post global to original value wp_reset_postdata();
The best way I know of would be to filter the data. For posts, you might do: function my_check_post_not_crazy( $data, $post_arr ) { $max_content_length = 2048; # max length in characters $max_num_posts = 200; # maximum number of posts if ( !current_user_can(‘activate_plugins’) && empty( $post_arr[‘ID’] ) ) { $die_args = array(‘back_link’ => true); # Not … Read more
This is what I ended up with. Totally does the trick, minus the sorting by last name. Would love to hear any additional thoughts on that. $display_admins = false; $order_by = ‘display_name’; // ‘nicename’, ’email’, ‘url’, ‘registered’, ‘display_name’, or ‘post_count’ $role=””; // ‘subscriber’, ‘contributor’, ‘editor’, ‘author’ – leave blank for ‘all’ $avatar_size = 32; $hide_empty … Read more
Here we go, found a nice thread which gave some answers and developed this which works a treat: if ( class_exists( ‘coauthors_plus’ ) ) { $co_authors = get_coauthors(); foreach ( $co_authors as $key => $co_author ) { $co_author_classes = array( ‘co-author-wrap’, ‘co-author-number-‘ . ( $key + 1 ), ); echo ‘<div class=”‘ . implode( ‘ … Read more
You can override the author link via the author_link filter: function wpd_author_link( $link, $author_id, $author_nicename ){ return ‘http://my.blog.tld/’; } add_filter( ‘author_link’, ‘wpd_author_link’, 20, 3 ); $author_id and $author_nicename are available to the filter so you can fetch whatever data you need to generate the correct link.
If you want to exclude ALL pages that doese’t have ‘collaborator’ set as author, then you want to exclude all other pages in the site and include all pages of that author minus, maybe, some hand picked pages of that author, then I think you can use this: add_filter(‘acf/fields/relationship/query/name=products’, ‘exclude_id’, 10, 3); function exclude_id ( … Read more