[Support request] Missing icon after adding in dynamic meta

Home Forums Support [Support request] Missing icon after adding in dynamic meta

Home Forums Support Missing icon after adding in dynamic meta

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2268830
    lewis

    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

    #2268836
    Fernando
    Customer Support

    Hi Lewis,

    Try using user_email as the meta field name.

    Kindly let us know how it goes.

    #2268855
    lewis

    Thanks. Email icon is now showing up, but does not seem to be dynamic, just opens to “gmail.com”. Thanks

    #2268861
    Fernando
    Customer Support

    Yes, 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!

    #2268863
    lewis

    Oh 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

    #2268868
    Fernando
    Customer Support

    To 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.

    #2268870
    lewis

    Hi 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

    #2268876
    Fernando
    Customer Support

    Are 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!

    #2268883
    lewis

    Hi Fernando, just made this quick vid to clarify. Thanks

    #2268916
    Fernando
    Customer Support

    Yes, 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/5zur92b0

    Then, 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!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.