Web Design, Programming, Tutorials
Adding social media icons to the Mystique theme
If you are using WordPress and the Mystique theme, such as this site, then the following instructions will help you with adding additional social icons above the menu bar.
Creating the images
The number of image files you need to create depends on the number of icons you wish to have. You can combine three icons per image file and use CSS to pull the desired icon from the file to display.
For example, below are the two image files used by this site. Since I only have six icons, I can make them all fit into two files. This is important because the browser only has to download two images to display these six icons. Each HTTP request back to the server can slow down a website. Using CSS to display the images also helps by allowing the browser to cache the images and reduce text in the HTML file.
These images were created in Photoshop using a transparent background. You can download various free social media icons. Search the internet and find some that you like that are 64 x 64 pixels. To create the tilted look, rotate the icon 30° and then resize so the height is 64 pixels. The total width of the image should be 64 x the number of icons, but remember to only store three per image file.
Changes to the CSS
Inside the Mystique theme, open the style.css file. Around 100 lines down into the file, you will see some code similar this:
#header .nav-extra
{width:64px;height:36px;display:block;position:absolute;bottom:18px;z-index:10;}
#header .nav-extra span
{display:none;}
#header .nav-extra.rss
{background:transparent url(images/nav-icons.png) no-repeat right top;right:20px;}
#header a.twitter
{background:transparent url(images/nav-icons.png) no-repeat left top;right:85px;}
Just below this block of CSS is where we will add our additions, which will be very similar to the last line of CSS implementing the twitter class on the “a” tag.
Add the following CSS to use the same image files and icons that I have used. You can change the name following the “a.” to anything you wish, but it should be something descriptive.
#header a.facebook
{background:transparent url(images/nav-icons.png) no-repeat center top;right:147px;}
#header a.myspace
{background:transparent url(images/nav-icons2.png) no-repeat right top;right:209px;}
#header a.flickr
{background:transparent url(images/nav-icons2.png) no-repeat center top;right:273px;}
#header a.linkedin
{background:transparent url(images/nav-icons2.png) no-repeat left top;right:338px;}
Here I have added additional icons for Facebook, MySpace, Flickr, and LinkedIn.
To reference the correct icon, using the background: CSS property, you can call the image file (nav-icons.png and nav-icons2.png). Using the top right, left and center keywords, you can select the icon file to use from the image. In the above example, the nav-icons.png file has three icons…by selecting the center one, I’m pulling out the Facebook icon from the first image above.
The “right” property positions the icon however many pixels from the right side of the screen. You can adjust this number to increase or reduce the amount of space between the icons.
Changes to the header
The last thing we need to do is add the HTML code to the header template. This will tell your browser to display the icons. Open the header.php file within the mystique theme, then look for the following block of code around line 55.
if ($twituser): ?>
<a href="http://www.twitter.com/<?php echo $twituser; ?>" class="nav-extra twitter"
title="<?php _e("Follow me on Twitter!","mystique"); ?>">
<span><?php _e("Follow me on Twitter!","mystique"); ?></span>
</a>
<?php endif; ?>
Next, we’ll add in our new icon HTML below the HTML shown above.
<a href="http://www.facebook.com/YOURPROFILE" class="nav-extra facebook"
title="<?php _e("My Facebook Profile.", "mystique"); ?>">
<span><?php _e("My Facebook Profile.", "mystique"); ?></span>
</a>
<a href="http://www.myspace.com/YOURPROFILE" class="nav-extra myspace"
title="<?php _e("My MySpace Profile.", "mystique"); ?>">
<span><?php _e("My MySpace Profile.", "mystique"); ?></span>
</a>
<a href="http://www.flickr.com/photos/YOURPROFILE/" class="nav-extra flickr"
title="<?php _e("My Flickr Photos.", "mystique"); ?>">
<span><?php _e("My Flickr Photos.", "mystique"); ?></span>
</a>
<a href="http://www.linkedin.com/in/YOURPROFILE" class="nav-extra linkedin"
title="<?php _e("My LinkedIn Profile.", "mystique"); ?>">
<span><?php _e("My LinkedIn Profile.", "mystique"); ?></span>
</a>
Make sure that you replace YOURPROFILE with the correct link information to your profile for these social media sites.
One thing that is important to notice is the CLASS attribute. There are two classes added to each “a” tag: nav-extra and the name of whatever social media icon you are displaying. This name must match the name specified in the CSS above that follows the “a.”.
about 2 years ago
Hey Jackson, the links to my categories are not working. Please help !!!!!
about 2 years ago
This post did not alter the category links. Check the theme’s website for support on the Mystique theme.
about 2 years ago
Dear Jackson,
Thanks for this post..Awesome its working great !
about 1 year ago
Awesome post, Im gonna have to try that soon.
about 1 year ago
1- First of all. My twitter icon was never there. I mean, when I install the theme. I´ve just had the RSS button. Why´s that?
2- I tried to do your thing, but I can´t find those lines on the header.php
3- How do I change de RSS link on the header, and on the footer (I want to add the Feedburner one)
Thanks…
about 1 year ago
@Enzo…
1 – You should add the twitter widget to your sidebar and enter your account info. The theme checks to see if you have configured twitter before it shows the icon.
2 – I suggest opening the header.php file in a text editor and doing a search for something like “$twituser” to find the lines.
3 – I would check the header.php and footer.php files for the HTML that creates the RSS icon and copy it for your Feedburner icon.
about 1 year ago
It looks like all of this functionality was moved into the file /wp-content/themes/mystique/extensions/xtra-nav/xtra-nav.php
An updated how-to might be nice ^_^
about 1 year ago
Very useful! Thanks!
about 1 year ago
@John David Eriksen
I haven’t had a chance to look at a newer version of the theme. If you’re having problems making these changes with the new theme, maybe search for the one used with this how-to. Looks like I’m using version 1.62.
about 1 year ago
Can you also please tell me how to change the code to change the NEXT and PREVIOUS posts links on top of the post?
The default is so light you cant even see it!
about 1 year ago
Why my website http://www.aquinohayquienviva.es dont show RSS and Twitter ICON in Firefox and yes in Internet Explorer?
about 1 year ago
That sounds like a CSS problem. If you are using firefox, you can download a plugin called firebug or IE Developer Tools for IE that will let you select any HTML element and view the current styles applied to it. They are very handy tools to use for web development.
about 1 year ago
I am having trouble finding what to do with the latest theme on Version 2.0 can anyone offer some advice?
about 1 year ago
very good post thanks
about 1 year ago
Hi Jackson,
Thank you for the great article. I will definitely give this a try. If you don’t mind, I got a different question for you. On my Mystique theme, whenever someone click on my user name to get to my profile page (http://vimlounge.net/#/?author=1), the whole thing seems out of proportion very badly. Is there a way to fix this?
about 1 year ago
If you’ve customized those templates, I would start by renaming what you have and uploading the original file(s) for the profile template. (It’s been a while since I’ve looked at these files, so I’m not sure which ones you’d need off hand). If the original template works fine, then I would begin making your customization changes again, but test what the page result looks like after each change to the template files or CSS. It may be a slow process, but you should be able to find it in the end. It looks to me like something in the CSS may be the problem.
about 1 year ago
I am not seeing the icons in Firefox either. It looks like the links are working, the images just aren’t showing up. Since it looks like you have not customized the template, you might see if there is a newer version available. Also, you might see if the creators might know why this is happening. Their website is http://digitalnature.ro/
about 1 year ago
Is there a way that you know of to make the icons mot move?
about 1 year ago
Hey Guyz,
I don’t know why, but this may help some of you people. Actually, I was not having the problem with the code. Fortunately, I just thought to open the nav icons through my browser to check. And see what happens. It says “You don’t have permissions to access the file”
So, I just saw that the images are not set as PUBLIC to all (CHMOD 777). So, when I made all images to 777 or PUBLIC, I was able to access them through my Browser and now it is working
Please check my website for Demo if you wish to see.
about 1 year ago
@Michael Kelly
Just breifly looking at the source code returned:
It looks like JQuery might be doing the animation. There is a class called “nav-extra” on each of those buttons.
You should be able to search the template code for something like $(‘.nav-extra’).animate(); to find it (or just search for the word animate).
Try commenting the JavaScript line out to see if it removes the animation.
EDIT: You may also need to search the /js/jquery.mystique.min.js file in the theme.
about 1 year ago
I have write post upon it. There is a plugin having lot of options. So if u want then check it. Link : http://www.namase.com/wordpress-tips-and-tricks/add-extra-nav-icons-to-mystique.shtml
about 1 year ago
I want help from you! In right upper corner there is two option Increase or decrease text size and second is switch from fixed to fluid page width. I am using same theme but it is showing only Increase or decrease text size option. How to enable switch from fixed to fluid page width. I have seen that image in my theme-image folder. But it is not showing in my website (www.namase.com).
Second is you are using Gravatar but in Sidebar tabs -> comments it is showing only comment default picture.
Thanks in advance. If u want to mail me then my mail id is namaserajesh@gmail.com. Please help me. I am trying it from long time. Thank you.
about 1 year ago
@Rajesh Namase
1 – I’m not sure where you are seeing the increase/decrease text size and switching from fluid to fixed page width. Admittedly, I’m using an older version of the theme, so there may be new options that I can’t see. I would search around and include the version number of your theme to find your answer.
2 – I took a look at your site and it looks like the gravatar image in your comments is working. I’m seeing the same image as I do for your comment on this page, so it looks like you already have that working.
Sorry I couldn’t help more…
about 1 year ago
Hi Chris,
Thank you for your reply. I found answer of my question my own.
“Page controls” – Increase or decrease text size and second is switch from fixed to fluid page width are in old theme. You are using old theme so both option are present. I think, it is best if you update your theme. Latest theme version is 2.4.2. I am using new version. Also don’t forget to check:
http://www.namase.com/wordpress-tips-and-tricks/40-most-wanted-mystique-theme-modifications-hacks.shtml
about 12 months ago
Thanks for this! I had the icons, but didn’t know you had to enter the information for my account. I thought it added it to their account. Much clearer now! Got it to work on Firefox
about 9 months ago
Really nice tutorial, this theme is really popular, I just made a spanish translation for Mystique, in case one of your visitor could use it I’ll leave the link -> http://geektual.com/tema-mystique-para-wordpress-en-espanol/