How to display User Information on the front end?
-
Hi all,
I am coding my own theme with the help of already developed html/css/js pages from webflow (I exported the code and am now converting the pages)
One thing I can’t figure is out, is how to display user information on the front end. For example, on my post template, I have a sidebar and have some html code there to display the author image, name and author bio. Here is the plain html code:
<div class="sidebar-div"> <div class="author-details-div"> <div class="author-image" style="background-image:url('<?php echo get_field( 'field name' ); ?>');"></div> <div class="author-text-div"> <h2 class="heading"> Author Name</h2> <p class="paragraph-2">Author Bio</p> </div> </div>
When googling on how to display the author name (as an example), I found these two options:
<?php echo get_the_author(); ?> and <?php get_the_author_meta( 'display_name', $author_id ); ?>
So I tried placing these code snippets in the h2 tag, like this:
<h2 class="heading"> <?php get_the_author_meta( 'display_name', $author_id ); ?></h2>
But it’s not working, nothing will be displayed on the front end.
I also added an acf image field to display on the backend for each user to set their profile pic. I want to display this acf image field on the front end with the other author details (see html code from above). The acf field is being displayed on the backend and I can set the image when editing user’s profiles, but when adding the php code to display the image on front end, it again won’t show.
However, if I change the acf field’s location in the backend, to be displayed on the post’s page (instead of the user profile page), then with the same php code, the image will be displayed.
So I guess there is something additional I have to do to display information that sits in the user profile in the backend? Can anyone help?
- The topic ‘How to display User Information on the front end?’ is closed to new replies.