- This topic has 27 replies, 4 voices, and was last updated 1 year, 2 months ago by David.
-
AuthorPosts
-
January 24, 2023 at 3:59 am #2506920Saul
I am looking to display some data from WordPress Users Profiles on Single Author Pages dynamically. I have already added the necessary fields and data using ACF, as seen in the screenshot provided (https://prnt.sc/Z4JUwvrKj3ZO). The goal is to show the data added for each individual Author/User on their respective profiles (ex: domain.com/author/author1, domain.com/author/author2, etc.). I have also created a Content Template Block where I am retrieving all data from the Author meta using GP’s Dynamic Data Feature (https://prnt.sc/c2mqwqB95BdS). However, there is currently no option in the Display rules to set the Template for for Single Author Pages.
Someone already asked this question (https://generatepress.com/forums/topic/single-post-author-template/) in the forum but there is no clear answer.
January 24, 2023 at 6:25 am #2507101DavidStaffCustomer SupportHi there,
there is no single
author.php
template in GeneratePress.
the theme uses thearchive.php
practically anywhere there is an archive ( aside from index.php ).
So you would use theAuthor Archive
display rule for that.If you use a Block Element – Loop template, this removes the default theme loop.
So you can use that element type, and populate it with dynamic data to make it your ownJanuary 25, 2023 at 1:00 am #2508179SaulThanks David! So… I turned my template to Block – Loop template from Block – Content Template which it was earlier. And, I set the template to display on “Author Archives” for “All Users” but there are two issues:
1. It’s not working for all users. It’s just working for one user and for the rest of the users it’s fetching no data.
2. Somehow the image added though the custom fields are not showing.Here is a video showing all setup: https://share.vidyard.com/watch/VBNSKzNyvcJctLSPhZCJAF?
January 25, 2023 at 1:12 am #2508199Fernando Customer SupportHi Saul,
Yes, can you share admin credentials so we can take a closer look?
Please use the Private Information field again for this.
January 25, 2023 at 2:59 am #2508308SaulSent it!
January 25, 2023 at 3:42 am #2508363DavidStaffCustomer SupportAre there any posts published ( not draft ) for those users who are missing their data ?
January 25, 2023 at 3:58 am #2508379SaulAh! I see. Other authors who I tested haven’t posted any post. And, if I assign any post(s) to an author without any post(s) then the profile shows data added though the custom fields. How, I can remove that check so that any author even without 0 posts shows the custom fields data. Also, the Profile Pic (the image) added through custom field is not showing on Author Profile.
January 25, 2023 at 4:45 am #2508426DavidStaffCustomer SupportYeah, thats tough, aside from creating a custom PHP template i am not sure on this. The issue arises is that the
$authordata
is only gathered in the loop. And as there are no posts to loop through there is no loop and therefore no dynamic data.What is the endgame here? Will all author have their own posts ?
January 25, 2023 at 6:50 am #2508544SaulMakes Sense! As such all Authors will have the posts so we are good. I just wanted to see if it’s possible to remove that check. But, I can understand what you said so let’s leave it. Can you please look into the Image thing and let me know how to fix that? The image added though Custom Field is not showing on the Author Profile.
January 25, 2023 at 6:59 am #2508555DavidStaffCustomer SupportAs any CF saved to the user would need to come from the Content Source:
Author Meta
.
And i don’t think the GB Image block supports that. If it doesn’t then we would need to create a shortcode or use arender_block
filter. Let me know.January 25, 2023 at 7:51 am #2508688SaulI double checked and Content Source:
Author Meta
is not available for the image.January 25, 2023 at 3:35 pm #2509184SaulSo how to approach this? If we add a shortcode with CF value for the image in place of the image will it show image added on each profiles dynamically?
On a separate thing… I am trying to create a Post Meta Section inline to this reference https://prnt.sc/K0q7lVS-Q8_p where I need to display Post Author and Medically reviewed by Author (Fact checked by author in my case). The fact checked by author will be a person from WordPress users list. To accomplish this I have already created a custom field, type “User” https://prnt.sc/s1HiUsHiUr77 which shows a dropdown (https://prnt.sc/nx_eUkeCh8p0) though which I can set any WP User as the Second Author/Fact Checker. I have used Post Meta Template to render this inside WP Posts. However, there are two issues:
1. The template is not Fact Checked by Author field value: https://prnt.sc/hl40O-XmvC5c and instead it’s showing the Author Name it’s showing Author ID.
2. I want the Post Meta to appear after Post’s H1 tag but there is no hook to render it after H1 tag.Please refer to this screenshot: https://prnt.sc/gngqdj-Pk921 (Test Post URL is sent privately).
January 25, 2023 at 4:24 pm #2509199DavidStaffCustomer SupportYeah, will need a shortcode to show the image.
Which is a bit more tricky then a straightforward field on a single post.
Not 100% sure on this, but give this a try for creating a shortcode for the user image:add_shortcode('show_user_image', function(){ $html = ''; $image = get_field('your_field_name', 'user_'. get_queried_object_id()); if ( $image ) { $html = '<img src="' . $image .'" width="150" height="150" />'; } return $html; });
You need to change the
your_field_name
to the actual field name,
Then just add the[show_user_image]
to your template.Give that a shot.
Regarding the other questions:
1. What is the Custom Field set to return in the ACF settings ?
2. How is that post template constructed ? The HTML is not the default GP Theme single post template?January 25, 2023 at 11:07 pm #2509383SaulThanks David! But no luck with that shortcode. It’s simply showing the image path: https://prnt.sc/-qv7mZh_0PPR for the user I am logged in with and for another user who has the posts it’s not showing anything: https://prnt.sc/4uBtyVwErlIF URLs for both profiles are sent privately.
Regarding your questions:
1. The custom field type is user: https://prnt.sc/EMhhCU4at87e which shows a dropdown (https://prnt.sc/nx_eUkeCh8p0) on all posts though which I can set any WP User as the Second Author/Fact Checker and trying to render the data on front-end using dynamic options: https://prnt.sc/hl40O-XmvC5c
2. The Post Template using WordPress’s default template. All posts in WP were actually HTML Pages in our old website which we migrated to WP using a custom PHP script.January 25, 2023 at 11:12 pm #2509385SaulURLs in the Private information field
-
AuthorPosts
- You must be logged in to reply to this topic.