You're browsing the category: Tutorials

Tutorials and snippets related to programming: Wordpress, HTML, CSS, jQuery, you name it.

Programming / Tutorials

WordPress: Display Author Info

This code is very useful if you have a WordPress website with multiple authors. The code will display a section with your gravatar, name and a little bio (the one you fill out in your user profile). This way, when people read an article written by you, they can see your info.

If you want this to appear on posts, you can add this snippet to single.php:

Feel free to style the classes (author-box, author-pic, author-name and author-bio) as you see fit on your CSS. The ‘100’ you see on the get_avatar function is the width and height of the gravatar. If it’s 100, then it would be 100×100, you can change it to any number.

If you have any questions, please let me know!

Programming / Tutorials

Javascript: Random Link Generator

This is a very simple code that you can use to generate random links. You can create a button, link, image with this function, which will randomly choose between the specified URLs to visit.

The first thing would be to create the array with the URLs There are two common ways to do this: The condensed array:

Or the regular array:

You can use any of these methods to create the generator, the next step is to create the function that will generate random links using the javascript Math.random method.

And that’s it! All that’s left is to add the HTML portion of the code, it can be a button, image, link, etc. I will use a link for this example:

This code can be modified to do many different things. For example, if you would like to display random quotes on your website, you could modify this code a little bit to make that happen. I will create a separate tutorial for that, though. Here’s the complete code from this tutorial:

If you have any questions, don’t hesitate to leave a comment.

Follow @_NicoleJeanette