- This topic has 9 replies, 2 voices, and was last updated 2 years, 2 months ago by Fernando.
-
AuthorPosts
-
June 30, 2022 at 12:01 am #2268830lewis
Hi there, I have added in the dynamic attributes for the icons for email as per the GP video. However, after saving, the email icon has no disappeared on the post. Here are the settings I currently have. https://imgur.com/a/V2zVxkM
June 30, 2022 at 12:13 am #2268836Fernando Customer SupportHi Lewis,
Try using
user_email
as the meta field name.Kindly let us know how it goes.
June 30, 2022 at 12:22 am #2268855lewisThanks. Email icon is now showing up, but does not seem to be dynamic, just opens to “gmail.com”. Thanks
June 30, 2022 at 12:31 am #2268861Fernando Customer SupportYes, that’s the default behavior if you set an email as the dynamic link type. It goes to the domain of the email.
Hope this clarifies!
June 30, 2022 at 12:34 am #2268863lewisOh ok. How do you make it so the email is actually pulled from the author profile? e.g. shelly@gmail.com. Also, what is the dynamic prompt for a link to the authors website? Thanks
June 30, 2022 at 12:39 am #2268868Fernando Customer SupportTo clarify, do you mean the email is copied when the button is clicked? If so, you would need Javascript for that.
The meta field name for the website is
user_url
.You’ll find other author meta field names here: https://developer.wordpress.org/reference/functions/get_the_author_meta/#description
Hope this clarifies.
June 30, 2022 at 12:42 am #2268870lewisHi there,
To clarify, when clicking on the email icon button, instead of being dynamic and linking to the email that is associated to the author profile page (e.g. shelly@gmail.com), all posts for all authors are linking to gmail.com instead of being dynamic. Thanks
June 30, 2022 at 12:52 am #2268876Fernando Customer SupportAre you wanting the Block to link to the Author’s archive page? If that’s what you’re going for, you should set the Dynamic Link type to Author Archive instead.
Hope this clarifies!
June 30, 2022 at 12:59 am #2268883lewisHi Fernando, just made this quick vid to clarify. Thanks
June 30, 2022 at 1:39 am #2268916Fernando Customer SupportYes, that’s the default behavior.
You would need custom code to alter the href for the link to behave in the way you want it to.
For instance, try adding
my-email
to the Classlist of the Block. Example: https://share.getcloudapp.com/5zur92b0Then, add this PHP snippet:
function db_rerender_email_url( $block_content, $block ) { if(!is_admin()){ if ( ! empty( $block['attrs']['className'] ) && 'my-email' === $block['attrs']['className'] ) { $my_search='href="'; $my_replace='href="mailto:'; $new_content = str_replace($my_search, $my_replace, $block_content); return $new_content; } } return $block_content; } add_filter( 'render_block', 'db_rerender_email_url', 10, 2 );
This code as modifies the href to add
mailto:
Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets
Hope this helps!
-
AuthorPosts
- You must be logged in to reply to this topic.