Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Gravatar to WP header
    primarykey
    data
    text
    <p>I would like to show the gravatar of the currently signed in user, and if the user has no gravatar it will show the default wp man (or img using URL)</p> <p>Here is the code I have at the moment;</p> <pre><code>&lt;div class="gravatar"&gt; &lt;img src="http://techyoucation.com/wp-content/themes/blank/images/treehouse.png" alt=""/&gt; &lt;/div&gt; </code></pre> <p>The code above just shows a random image that I would like to change to the signed in user's gravatar (When no users are signed in, it will hide but I will make that happen later).</p> <p>So does anyone know what to I need to do in order to make it work?</p> <p>Thanks in advance</p> <p>Aled </p> <p><strong>UPDATE</strong></p> <p>Using </p> <pre><code>&lt;div class="logo"&gt;&lt;a href="http://techyoucation.com"&gt;&lt;img src="&lt;?php $user_id = get_current_user_id() // Get the user ID $size_avatar = 50 // Set the avatar size $default_avatar = 'http://techyoucation.com/wp- content/themes/blank/images/treehouse.png' // Set your default image url echo get_avatar( $user_id, $size_avatar, $default_avatar ); ?&gt;" alt="techyoucation logo" width="219" height="47" id="Logo" /&gt;&lt;/a&gt;&lt;/a&gt; </code></pre> <p>Dreamweaver says there are 3 syntax errors? Have I used your code wrong?</p> <p>Thanks</p> <p><strong>UPDATE</strong></p> <p>Okay so now I have;</p> <pre><code>&lt;div class="gravatar"&gt; &lt;img src="&lt;?php $user_id = get_current_user_id(); // Get the user ID $size_avatar = 50; // Set the avatar size $default_avatar = 'http://techyoucation.com/wp-content/themes/blank/images/treehouse.png'; // Set your default image url echo get_avatar( $user_id, $size_avatar, $default_avatar ); ?&gt;" alt=""/&gt; &lt;/div&gt; </code></pre> <p>but the image don't show. When I right click and select copy image URL it gives me "<a href="http://techyoucation.com/%3Cimg%20alt=" rel="nofollow">http://techyoucation.com/%3Cimg%20alt=</a>''%20src='<a href="http://0.gravatar.com/avatar/?d=http://techyoucation.com/wp-content/themes/blank/images/treehouse.png&amp;s=50" rel="nofollow">http://0.gravatar.com/avatar/?d=http://techyoucation.com/wp-content/themes/blank/images/treehouse.png&amp;s=50</a>'%20class='avatar%20avatar-50%20photo%20avatar-default'%20height='50'%20width='50'%20/%3E" </p> <p>Any ideas.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload