Topic: [1.5] Adding extra social links to the nav bar

There are quite a lot of you who want to know how to add sociallinks to the quick navigation. Here's a quick tutorial how. I'm not going to bother with adding options since that requires some more work but if people are interested in that I'll do a write-up on that.

In this example I'm going to add a link to my YouTube Channel.  (This functions goes in functions.php)

function add_extra_sociallinks() { 
            ?>
        <li><a id="youtube" title="<?php printf( __( '%s on YouTube', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.youtube.com/user/watkijkikoptv" target="_blank"><?php _e('YouTube', 'arras') ?></a></li>
        <?php 
}
add_action('arras_quick_nav', 'add_extra_sociallinks'); 

Now all that is needed is a 16x16 icon which will be added to user.css or style.css (if you use a Child Theme).

.quick-nav #youtube { background: url(images/youtube.png) no-repeat; }

Last edited by extatix (2010-09-27 04:40:17)

My Arras themed & Arras related site: NullCore.
Please ask questions about Arras on forum, not through mail, thanks.

Re: [1.5] Adding extra social links to the nav bar

Soory I don't understand where to put both codes.

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

It actually says where smile

The first part in functions.php and the second part in user.css, but you need to put a youtube.png in the images folder of course, sized 16x16.

My Arras themed & Arras related site: NullCore.
Please ask questions about Arras on forum, not through mail, thanks.

Re: [1.5] Adding extra social links to the nav bar

Ex-

I just downloaded 1.5 to my "backend" to customize before I go "live." I tried following your above directions for adding the social links in my navbar but it didn't work.

Does the first code have to go in a certain place in fuctions.php? I put mine at the beginning like this:
<?php
wp_enqueue_script('jquery');

function add_extra_sociallinks() {
            ?>
        <li><a id="youtube" title="<?php printf( __( '%s on YouTube', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.youtube.com/user/veracitystew" target="_blank"><?php _e('YouTube', 'arras') ?></a></li>
        <?php
}
add_action('arras_quick_nav', 'add_extra_sociallinks');

Also...I added the other part of the code to my user.css like this: (note: there is no "images" folder like your instructions said)--

#header                    { background: #DDDDDD; }

.blog-description                { display: none; }

.quick-nav #youtube { background: url(stewtwo/wp-content/uploads/2010/10/youtube.png) no-repeat; }

My image is "youtube.png" is 16x16 pxls and was uploaded into my media directory uploads/2010/10/youtube.png

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

It doesn't matter much where in functions.php actually, as long it's not interferring with another function that is.

Last edited by extatix (2010-11-01 02:44:18)

My Arras themed & Arras related site: NullCore.
Please ask questions about Arras on forum, not through mail, thanks.

Re: [1.5] Adding extra social links to the nav bar

extatix wrote:

It doesn't matter much where in functions.php actually, as long it's not interferring with another function that is.

Hey Ex -- As I said in my other post, I'm customizing Arras 1.5.0.1 (no child theme) on the backend of my server until I'm satisfied with it. But as I mentioned above, I've been trying to use your instructions for adding the social links/icons in the nav bar and it doesn't work....what am I missing here?

I put the first code just after the beginning of my functions.php file:

<?php
wp_enqueue_script('jquery');

function add_extra_sociallinks() { 
            ?>
        <li><a id="youtube" title="<?php printf( __( '%s on YouTube', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.youtube.com/user/veracitystew" target="_blank"><?php _e('YouTube', 'arras') ?></a></li>
        <?php 
}
add_action('arras_quick_nav', 'add_extra_sociallinks'); 

I inserted the other part in my User.css (at the bottom)

.quick-nav #youtube { background: url(http://boweeb.ipower.com/stewtwo/wp-content/uploads/2010/10/youtube.png) no-repeat; }

http://www.veracitystew.com/stewtwo

thanks for the help,
Steve

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

See http://www.arrastheme.com/forums/post17652.html#p17652 smile

My Arras themed & Arras related site: NullCore.
Please ask questions about Arras on forum, not through mail, thanks.

Re: [1.5] Adding extra social links to the nav bar

I've almost got it, but it isn't showing the png picture. There's a link there if you roll over it, but it isn't showing the image.

http://arenapigskin.byethost5.com/

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

Hey all,

I wanted to add a social link to the header for LinkedIn, but also wanted to add the option into the Arras theme settings so others could easily change it...so I went ahead and figured out how. Thought I'd add a simple step-by-step tutorial here so others can do the same.

This is for Arras v1.5, btw...

Note: You can replace the word 'linkedin' with the name of whatever social networking site you want to add.

Here are the files you'll need to edit:

library/admin/options.php
library/admin/templates/arras-general.php
user.css
library/template.php

And here is what you need to do for each:

STEP 1: Edit options.php

Line 7: After

$facebook_profile,

add:

$linkedin_profile,

Line 121: After

$this->facebook_profile = (string)$_POST['arras-facebook'];

add a new line:

$this->linkedin_profile = (string)$_POST['arras-linkedin'];

STEP 2: Edit arras-general.php

After Lines 52-58, add these new lines:

<tr valign="top">
<th scope="row"><label for="arras-linkedin"><?php _e('LinkedIn Profile (URL)', 'arras') ?></label></th>
<td>
<?php echo arras_form_input(array('name' => 'arras-linkedin', 'id' => 'arras-linkedin', 'class' => 'code', 'size' => '65', 'value' => arras_get_option('linkedin_profile') )) ?><br />
<?php _e('Link to your LinkedIn profile.', 'arras') ?>
</td>
</tr>

STEP 3: Edit user.css

Add:

.quick-nav #linkedin    { background: url(images/linkedin.png) no-repeat; }

Because you're adding icons to your nav bar, you'll want to prevent your page links from running into them. For this reason, you'll need to do some math and calculate the width of the added icons (16px is the size of the icons that come with this theme, +8px for padding).

You then need to subtract that number from 770px to determine the max-width of your nav menu.

Here is the code for adding just one new, 16px wide link:

#nav .sf-menu  { max-width: 746px; }

Optional: I wanted to use larger icons, so I also added:

.quick-nav a:link, .quick-nav a:visited    { margin-top: -6px; width: 24px; height: 24px; }

STEP 4: Edit template.php

After Lines 308-311, add these new lines:

        <?php $linkedin_profile = arras_get_option('linkedin_profile'); ?>
        <?php if ($linkedin_profile != '') : ?>
            <li><a id="linkedin" title="<?php printf( __( '%s LinkedIn', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="<?php echo $linkedin_profile ?>" target="_blank"><?php _e('LinkedIn', 'arras') ?></a></li>
        <?php endif ?>

STEP 5: Upload new social network icon

You'll need to create an icon image file. I created 'linkedin.png' for the example above, which gets referenced in the CSS code in Step 3. The standard link size for Arras is 16 x 16 px.

Make sure you name your file the same as you indicate in your CSS, then upload it to the theme/images folder. I've attached the social link images I created, which are larger (24 x 24 px).

And that's it!

Now when you edit your Arras options, under the General tab you will see a spot to enter your new social network link.

Last edited by xtventures (2010-11-18 10:51:15)

Post's attachments

social-links.zip 18.56 kb, 13 downloads since 2010-11-18 

You don't have the permssions to download the attachments of this post.

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

I always think it's a horrible idea to do these things in Arras itself, better is do it in a Child Theme.

My Arras themed & Arras related site: NullCore.
Please ask questions about Arras on forum, not through mail, thanks.

Re: [1.5] Adding extra social links to the nav bar

Agreed.

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

I'm having the same problem as ArenaPigskin. I followed the original directions but changed it to StumbleUpon. The script is there and works fine but the image seems to be invisible. Any ideas on how to fix it?

I'm using the Arras 1.5.0.1

Thanks - Jenn
www.frugalfrontporch.com

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

Well, this is weird. Whatever caused the problem I mentioned above seems to have worked itself out. Thanks for the theme hack. big_smile

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

I also have the problem with the social link (youtube) icon  bein invisible. I followed the instructions in the first post but I can't figure out why the pic is not showing (www.techgirl.se)

JeenAtFFP: do you have any idea why your problem worked it self out? Any help would be appriceiated.

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

Hi!!! I have a problem with the image...

http://i53.tinypic.com/1zywmts.jpg

I  create the link but the picture isn't visible...

What I can do?

Thanks ^^

My website is www.deskaradosfm.com

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

I still have this problem. The code into functions.php and user.css but no change. Youtube logo remains invisible. This is really bugging me!

On top of that, now my Twitter icons wont show. Tried removing the text in the arras admin gui, but no change. Social links are just not copperative.

www.techgirl.se

Last edited by KimmyN (2011-04-11 12:18:26)

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

Would like to bump this as I have invisible icons to

functions.php
function add_extra_sociallinks() {
            ?>
        <li><a id="youtube" title="<?php printf( __( '%s on YouTube', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.youtube.com/user/myMixVent" target="_blank"><?php _e('YouTube', 'arras') ?></a></li>

        <li><a id="Facebook" title="<?php printf( __( '%s on Facebook', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.facebook.com/myMixVent" target="_blank"><?php _e('Facebook', 'arras') ?></a></li>

        <li><a id="Twitter" title="<?php printf( __( '%s on Twitter', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.twitter.com/user/myMixeEnt" target="_blank"><?php _e('Twitter', 'arras') ?></a></li>

        <li><a id="Steam" title="<?php printf( __( '%s on Steam', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://steamcommunity.com/groups/myMixVent" target="_blank"><?php _e('Steam', 'arras') ?></a></li>

        <li><a id="Mirc" title="<?php printf( __( '%s on Mirc', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="irc://irc.quakenet.org/mmv.com" target="_blank"><?php _e('Mirc', 'arras') ?></a></li>

        <li><a id="Ventrilo" title="<?php printf( __( '%s on Ventrilo', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="ventrilo://voice.mymixvent.com:4667/servername=MyMixVent" target="_blank"><?php _e('Ventrilo', 'arras') ?></a></li>
        <?php
}
add_action('arras_quick_nav', 'add_extra_sociallinks');

style.css
.quick-nav #youtube { background: url(images/youtube_x16.png) no-repeat; }
.quick-nav #facebook { background: url(images/facebook_x16.png) no-repeat; }
.quick-nav #twitter { background: url(images/twitter_x16.png) no-repeat; }
.quick-nav #steam { background: url(images/steam_x16.png) no-repeat; }
.quick-nav #mirc { background: url(images/mirc_x16.png) no-repeat; }
.quick-nav #ventrilo { background: url(images/ventrilo_x16.png) no-repeat; }

*****FIXED****

Make sure  "<li><a id="ventrilo" title=" is the same as "url(images/ventrilo_x16.png)" as in the same case and not Ventrilo and ventrilo. Simple I know but took a few hours.

Last edited by skittles (2011-05-02 06:57:29)

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

Helloo everyone i thought that i would register and reply to everyone that is having the invisible icon problems as i have the same problem and managed to get it to work, i will explain how i solved it while messing around having the same problem at my site Aylingtek.co.uk

Like extatix posted

function add_extra_sociallinks() { 
            ?>
        <li><a id="youtube" title="<?php printf( __( '%s on YouTube', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.youtube.com/user/watkijkikoptv" target="_blank"><?php _e('YouTube', 'arras') ?></a></li>
        <?php 
}
add_action('arras_quick_nav', 'add_extra_sociallinks'); 

Is correct, but remember to change the channel URL to your one.

However it was the code that you put in the user.css what was wrong, the code itself is correct just the location looking for the youtube.png file.

I will give you an example of what i did on my website to get it to work.

Instead of having this

.quick-nav #youtube { background: url(images/youtube.png) no-repeat; }

Have this, as this code has to link directly to the youtube.png file and not just (images/youtube.png)

.quick-nav #youtube { background: url(http://www.aylingtek.co.uk/wp-content/themes/arras/images/youtube.png) no-repeat; }

As you can see the url links directly to my image, by linking to the image like this it will show in the arras theme without a problem.

Hope i helped the people who were having this problem.

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

My problem seem to be rather unsual.
When I first tried to add a YouTube link, the whole site stopped to load. Then I repeated steps in the guide two or three times and it started to work.
Now I try to add another button but it always stops working. It just doesn't load. Did I forget to close any function or smth?
Here's my part of code, which I try to put in functions.php

// VKontakte navbar button
function add_extra_sociallinks() { 
            ?>
        <li><a id="vkontakte" title="<?php printf( __( '%s ВКонтакте', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://vk.com/realstandup" target="_blank"><?php _e('vkontakte', 'arras') ?></a></li>
        <?php 
}
add_action('arras_quick_nav', 'add_extra_sociallinks');
Keep trying to set up Arras theme on http://standup-sreda.ru.

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

Hello! I am adding extatix's code in functions.php of my child theme. The icon appears and the site works, but I am getting this error message when I save a file with Wordpress media library:

Warning: Cannot modify header information - headers already sent by (output started at .../functions.php:62) in ..../wp-includes/pluggable.php on line 897

Line 62 is where I made the change and where the new code starts.

Can anyone help?

Thank you.

My Arras Site: Geo5.net

Re: [1.5] Adding extra social links to the nav bar

I am also getting this warning when I upload an image to the media library.  neutral

Warning: Cannot modify header information - headers already sent by (output started at .../functions.php:62) in .../wp-admin/async-upload.php on line 26

My Arras Site: Geo5.net

Re: [1.5] Adding extra social links to the nav bar

I am not a programmer yet and I think something may be missing in functions.php of my child theme.
The problem started when I added the new code.
Please, have a look. Any help will be appreciated.

<?php
/* Edits post header */
/* New function to replace arras_postheader */
function my_postheader() {
    global $post, $id;
    
    $postheader = '';

        if ( function_exists('yoast_breadcrumb') ) {yoast_breadcrumb('<p id="breadcrumbs">','</p>');
        } 
   
    if ( is_single() || is_page() ) {
    
        if ( is_attachment() ) {
            $postheader .= '<h1 class="entry-title">' . get_the_title() . ' [<a href="' . get_permalink($post->post_parent) . '" rev="attachment">' . get_the_title($post->post_parent) . '</a>]</h1>';
        } else {
            $postheader .= '<h1 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h1>';
        }
        
    } else {

        if ( is_attachment() ) {
            $postheader .= '<h2 class="entry-title">' . get_the_title() . ' [<a href="' . get_permalink($post->post_parent) . '" rev="attachment">' . get_the_title($post->post_parent) . '</a>]</h2>';
        } else {
            if (!is_page()) $postheader .= '<a class="entry-comments" href="' . get_comments_link() . '">' . get_comments_number() . '</a>';
            $postheader .= '<h2 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h2>';
        }
  
   }
    
    if ( !is_page() ) {
        $postheader .= '<div class="entry-info">';
    
        if ( arras_get_option('post_author') ) {
            $postheader .= sprintf( __('<div class="entry-author">By %s</div>', 'arras'), '<address class="author vcard"><a class="url fn n" href="' . get_author_posts_url( get_the_author_meta('ID') ) . '" title="' . esc_attr(get_the_author()) . '">' . get_the_author() . '</a></address>' );
        }
        
        if ( arras_get_option('post_date') ) {
            $postheader .= '<abbr class="published" title="' . get_the_time('c') . '">' . get_the_time(get_option('date_format')) . '</abbr>';
        }
        
        if (current_user_can('edit_post')) {
            $postheader .= '<a class="post-edit-link" href="' . get_edit_post_link($id) . '" title="' . __('Edit Post', 'arras') . '">' . __('(Edit Post)', 'arras') . '</a>';
        }

        
        $postheader .= '</div>';
        
    }
    
    if ( arras_get_option('single_thumbs') && has_post_thumbnail($post->ID) ) {
        $postheader .= '<div class="entry-photo">' . arras_get_thumbnail('single-thumb') . '</div>';
    }
        
    return $postheader;
}
add_filter('arras_postheader', 'my_postheader');

?>


<?php
/* add extra social link to quick nav */
function add_extra_sociallinks() { 
            ?>
        <li><a id="youtube" title="<?php printf( __( '%s on YouTube', 'arras' ), esc_html( get_bloginfo('name'), 1 ) ) ?>" href="http://www.youtube.com/user/xxxxxx" target="_blank"><?php _e('youtube', 'arras') ?></a></li>
     
      <?php
}
add_action('arras_quick_nav', 'add_extra_sociallinks'); 

 ?>
My Arras Site: Geo5.net

Re: [1.5] Adding extra social links to the nav bar

Added the following code to the functions.php file to insert a Google +1 button to the quick nav:

function add_extra_sociallinks() { 
            ?>
        <li><a id="plusone"<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
<g:plusone size="small"></g:plusone></a></li>
        <?php 
}
add_action('arras_quick_nav', 'add_extra_sociallinks'); 

Thumbs up

Re: [1.5] Adding extra social links to the nav bar

Trying and learning: everything is working now. I had to remove ?> and <?php before the new code and the ?> in the end of the file.

My Arras Site: Geo5.net

Re: [1.5] Adding extra social links to the nav bar

hi

i added this code, but it seems to be working only in firefox. safari and IE dont display the google +1 field.

any ideas?

thanks
conte

Thumbs up