国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
What is Gravatar and why should I display it?
Method 1: Edit your WordPress theme (best for consistency)
Home CMS Tutorial WordPress How to display avatar in user email in WordPress

How to display avatar in user email in WordPress

Apr 18, 2025 am 10:51 AM

Do you want to display avatars in user emails in WordPress?

Gravatar is a network service that connects a user's email address to an online avatar. WordPress automatically displays visitors’ profile pictures in the comments section, but you may also want to add them to other areas of the site.

In this article, we will show you how to display avatars in user emails in WordPress.

How to display avatar in user email in WordPress

What is Gravatar and why should I display it?

Gravatar stands for globally recognized avatars, which allows people to link images to their email addresses.

If the website supports Gravatar, it can take a photo of the person and display it next to their name. For example, when a user leaves a comment with an email on a WordPress website, WordPress displays the person's avatar next to the comment.

How to display avatar in user email in WordPress

Avatars can encourage users to participate in conversions, build a sense of community, and make your page look more interesting. All of this adds up to help you get more comments on your WordPress posts.

Depending on how your website is set up, WordPress may display avatars elsewhere, such as an author profile. However, you may want to change the location where the user avatar appears on a WordPress blog or website. For example, you can display a user's avatar in the website's toolbar or in the user profile.

That being said, let's see how to display Gravatar in user emails in WordPress. Simply use the quick link below to jump to your favorite method:

  • Method 1: Edit your WordPress theme (best for consistency)
  • Method 2: Use custom WordPress shortcodes (fully customizable)

Method 1: Edit your WordPress theme (best for consistency)

First, you can add Gravatar to your WordPress theme using code. This is a great option if you want to display avatars in the same location on the entire website (such as the sidebar or above the title). However, you need to edit the template file, so this is not the best way for beginners.

This method displays the avatar of the person currently logged into your website. This is very useful for member websites, online stores, or any other website where users must log in to their account.

To add Gravatar to your theme, you need to paste some code into your theme file. If you haven't done this before, check out our beginner's guide to paste clips from web pages into WordPress.

The easiest way to add code snippets to your WordPress website is to use WPCode. It is the best code snippet plugin for WordPress, allowing you to add PHP, CSS, JavaScript, and more to your website.

First, you need to install and activate the free WPCode plugin. If you need help, see our guide on how to install WordPress plug-ins.

Once activated, go to Code Snippets in the WordPress dashboard ? Add Snippets. Now click the "Add New" button.

How to display avatar in user email in WordPress

This will take you to the Add Fragments page where you will see all the ready-made snippets that WPCode can add to your website.

Here, hover over "Add Custom Code (New Snippet)" and click it when the Use Snippet button appears.

How to display avatar in user email in WordPress

First, enter the title of the code snippet. This is for your reference only, so you can use whatever you want.

After that, open the Code Type drop-down list and select PHP Fragment.

How to display avatar in user email in WordPress

You can now proceed to paste the following into the code editor:

How to display avatar in user email in WordPress

When you are done, scroll to the top of the page and click the Inactive switch to make it appear Active.

Then, just click the "Save Fragment" button.

How to display avatar in user email in WordPress

You can now use the following function to display the user's Gravatar anywhere on your WordPress site:

How to display avatar in user email in WordPress

Just like Method One, this method will display the current user's avatar. If you prefer, you can display the avatar assigned to a specific email address by making simple changes to the code.

This can be very useful if you have someone’s email address and want their avatar to be displayed on your website, but they are not registered users.

The easiest way to create a custom shortcode is to use WPCode. Better yet, you don't have to edit the topic file, so this is a more beginner-friendly way.

If you haven't installed it, then you need to install WPCode. You also need to follow the same procedure above to create a new custom code snippet.

Once done, name the code snippet and select "PHP Snippet" as the code type.

How to display avatar in user email in WordPress

Next, paste the following PHP into the code editor:

How to display avatar in user email in WordPress

You can now use the following shortcode to display the user's avatar on any page, post, or widget ready area:

How to display avatar in user email in WordPress

You can then paste your custom CSS into a small code editor.

Once done, just click Publish.

How to display avatar in user email in WordPress

Now if you visit your website you will see a new style of avatar.

For more tips on customizing Gravatars on your website, see our guide on how to change Gravatar image size in WordPress.

How to add custom short codes using the full site editor

If you are using one of the newer block-based themes, you can add shortcodes to any template or template section. This allows you to display avatars of users throughout the site without editing the template file.

For example, you can add a shortcode to the blog template or title template section of a website.

First, go to the Appearance ? Editor in the WordPress dashboard.

How to display avatar in user email in WordPress

By default, the full site editor displays the main template for the theme, but you can add shortcodes to any template or template section, such as header or footer.

To see all available options, simply select Template or Template Parts.

How to display avatar in user email in WordPress

You can now click on the template or template section you want to edit.

For example, we will add shortcodes to the 404 page template, but the steps will be exactly the same no matter which template you choose.

How to display avatar in user email in WordPress

WordPress will now display a preview of the template or template section.

To add a short code, go ahead and click the small pencil icon.

How to display avatar in user email in WordPress

When you are done, click the blue " " icon in the upper left corner.

In the search bar, continue to enter "Short Code".

How to display avatar in user email in WordPress

When the right block appears, drag and drop it onto the theme template.

You can now paste the short code or enter [wpb_gravatar] into this block.

How to display avatar in user email in WordPress

After that, go ahead and click the Save button.

Now, just visit your WordPress blog to view the running Gravatar.

How to display avatar in user email in WordPress

We hope this article helps you understand how to display Gravatar in user emails on your WordPress website. You may also want to check out our pick of the best social media plugins and a guide on how to create a contact form in WordPress.

The above is the detailed content of How to display avatar in user email in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1504
276
What is the minimum PHP version for WordPress What is the minimum PHP version for WordPress Jul 10, 2025 am 11:21 AM

WordPressrequiresatleastPHP7.4,thoughusing8.0orhigherisrecommendedforbetterperformanceandsecurity.Olderversionslike5.6areoutdated,unsupported,andposesecurityrisks.UsingupdatedPHPimprovessecurity,enhancesperformance,andensurescompatibilitywithmodernpl

How to optimize WordPress robots txt How to optimize WordPress robots txt Jul 13, 2025 am 12:37 AM

robots.txt is crucial to the SEO of WordPress websites, and can guide search engines to crawl behavior, avoid duplicate content and improve efficiency. 1. Block system paths such as /wp-admin/ and /wp-includes/, but avoid accidentally blocking the /uploads/ directory; 2. Add Sitemap paths such as Sitemap: https://yourdomain.com/sitemap.xml to help search engines quickly discover site maps; 3. Limit /page/ and URLs with parameters to reduce crawler waste, but be careful not to block important archive pages; 4. Avoid common mistakes such as accidentally blocking the entire site, cache plug-in affecting updates, and ignoring the matching of mobile terminals and subdomains.

How to use InspectorControls in Gutenberg How to use InspectorControls in Gutenberg Jul 12, 2025 am 12:16 AM

InspectorControls is a component used in Gutenberg development to add custom controls in the right sidebar. 1. It belongs to the @wordpress/block-editor package. 2. It is often used with PanelBody, TextControl and other components. 3. When using it, you need to introduce and reasonably lay out control types such as text boxes, pull-down selections, switches, sliders and color selectors in edit.js. 4. Pay attention to grouping settings, keep them simple, support internationalization and optimize performance.

How to apply security headers in WordPress How to apply security headers in WordPress Jul 11, 2025 am 12:40 AM

It is not complicated to add security response headers in WordPress, and can be implemented through server configuration, security plug-ins, or CDN. 1. Add header information such as X-Content-Type-Options, X-Frame-Options, etc. through Apache or Nginx configuration files; 2. Use plug-ins such as Wordfence and iThemesSecurity to simplify settings; 3. Use the built-in functions of CDN platforms such as Cloudflare to configure global header information. After configuration, you should use SecurityHeaders.com or ChromeDevTools to test and verify to ensure correctness and get at least A-level scores, while paying attention to backup and understanding the enabled

How to secure the wp-configphp file How to secure the wp-configphp file Jul 12, 2025 am 12:14 AM

To protect the security of WordPress sites, we need to focus on protecting wp-config.php files. 1. Restrict external access to wp-config.php through server configuration (such as Apache's .htaccess or Nginx configuration); 2. Set reasonable file and directory permissions, and it is recommended to set wp-config.php permission to 600; 3. Move wp-config.php to the non-public directory at the upper root of the website to improve security; 4. Ignore the file in the version control system to avoid leakage of sensitive information; 5. Regularly update the security key in wp-config.php to prevent the risk of session hijacking. These measures can effectively improve WordPress security

How to optimize the WordPress database How to optimize the WordPress database Jul 14, 2025 am 12:05 AM

Optimizing WordPress database can effectively improve website speed and stability. Key steps include: 1. Clean up useless data, such as spam comments, revisions and drafts. You can limit the number of revisions by modifying configurations or plug-ins and delete invalid content in batches; 2. Optimize database tables, use plug-ins or SQL commands to repair and compress fragmented tables to improve query efficiency; 3. Delete residual data of plug-ins and topics that are no longer used to avoid taking up space and causing conflicts, and manually clean up legacy configurations if necessary; 4. The database must be fully backed up before operation, and data can be exported with the help of plug-ins or control panels to ensure security. Perform the above regularly to keep the website running efficiently.

How to use Advanced Custom Fields ACF How to use Advanced Custom Fields ACF Jul 13, 2025 am 12:09 AM

The key to using ACF is to understand its workflow and application scenarios. The specific steps are as follows: 1. Create a custom field group, enter the "CustomFields" menu in the background, add a field group and set display rules; 2. Call field data in the template, display the field content through the PHP function the_field or get_field; 3. Use the option page to achieve global settings, add an option page through the code and call global fields; 4. Pay attention to the field naming specification, field group order, export field group and local development synchronization and other tips. After mastering these steps, ACF can significantly improve WordPress development efficiency.

How to display posts with specific tags How to display posts with specific tags Jul 10, 2025 am 11:33 AM

The way to present a specific tag article depends on the platform or framework. ① WordPress can use WP_Query or get_posts() functions to retrieve the specified tag content; ② Static site generators such as Hugo can configure templates to automatically list related articles; ③ Self-development requires front-end filtering data or back-end interface parameters to filter; ④ When implementing, pay attention to case, multi-label logical relationship, paging and exception handling.

See all articles