treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress template

  • Hi there newbie here.

    I only just start using wordpress and learning how to design my own theme from CSS Videos 'Designing for Wordpress'.
    P.S thanks a lot Chris Coyier your the man, there is so much info to gain from your site. But one video at a time :D .

    I have stumbled across a few errors on the third video of 'Designing for Wordpress'. I cant figure out why my gravatar is not working properly. By the way, I am using a virtual host 'XAMPP' for installing wordpress. I activated the gravatar plugin but it is not working.

    Here is the error:
    Error

    Fatal error: Call to undefined function gravatar() in C:\Program Files\xampp\htdocs\wordpress\wp-content\themes\blank\comments.php on line 43

    PHP file: comments.php
    <img src="images/search.jpg" alt="" style="margin-top: -10px;" />

    <img src="<?php gravatar('R', 125, 'images/gravatar.jpg'); ?>" alt="Gravatar" class="floatleft" />


    Any suggestions what I'm doing wrong here?

    Many thanks in advance
    CHEERS :)
  • Damn I must be the only one with this kind of error :shock:
  • I'm not sure where you got that code from so it's difficult to say.

    As of Wordpress 2.5 Gravatar support is built-in. The theme function for accessing gravatars is get_avatar(), which returns a complete <img> tag of the avatar.

    Prior to 2.5 support for Gravatar was provided by plugins, so the code you have may require you to install a plugin to work properly.
  • "davesgonebananas" said:
    I'm not sure where you got that code from so it's difficult to say.

    As of Wordpress 2.5 Gravatar support is built-in. The theme function for accessing gravatars is get_avatar(), which returns a complete <img> tag of the avatar.

    Prior to 2.5 support for Gravatar was provided by plugins, so the code you have may require you to install a plugin to work properly.

    Hi dave,

    Thanks, I'm just happy someone replied back to me :D .

    I actually got this code from Chris Coyier's video tutorial 'Design for wordpress' and followed everything until this minor hiccup.

    Are you able to show me a sample of that script and how it works? Like where do I put
    'The theme function for accessing gravatars is get_avatar()'
    code?
  • Ok, I have found the tutorial and downloaded the template. The template relies on an old plugin (Gravatar) which has been replaced by the built-in functionality in Wordpress now (I think).

    You can update the template by replacing the line in comments.php:
    <img src=\"<?php gravatar(\"R\", 40, \"http://css-tricks.com/wp-content/themes/CSS-Tricks/images/missing-gravatar.png\"); ?>\" alt=\"Gravatar\" class=\"gravatar\" /> 

    with
    <?php echo get_avatar($comment->comment_author_email, 40, \"http://css-tricks.com/wp-content/themes/CSS-Tricks/images/missing-gravatar.png\"); ?> 


    And in style.css change:
    .gravatar							{ margin-top: 3px; padding: 2px; height: 40px; }

    to
    .avatar							{ margin-top: 3px; padding: 2px; height: 40px; }
  • Oh my GOD, oh my GOD it worked Dave, it really worked..thank you thank you :D :D ;) .
    Now I understand why it didn't work in the first place :roll: .

    I have the avatar in place now, so all I have to do is align the comment tip and bubble with the CSS. So hopefully no more dramas with this :mrgreen: .

    Thanks heaps Dave.
    CHEERS :)