Falcon1986-Online

Home of a med student who likes to manage websites and talk tech!

Archive for the ‘Wordpress’ Category

Add/remove contact info fields in WordPress user profiles

with 2 comments

WordPress LogoNot many subscribers to WordPress blogs take the time to fill out contact information on their profile pages. Perhaps a reason for this is that the area is not well promoted, but it could also be that the contact fields are not relevant to some people. The default profile page for WordPress users include input fields for AIM, YIM and Jabber, among others, but wouldn’t it be great if you could add other fields to the set or remove a few of the existing ones? Quite a few people use Facebook and Twitter; why not add fields so they can link to their presence on these social networks? In this post, I will show you how it can easily be done by editing your theme’s functions.php file.

Locate your theme’s functions.php file and open it in a simple text editor. Append with the following lines of code and modify depending on which fields you want to add or remove. Save and visit your profile to test.

// Add extra contact info to user profile page
function extra_contact_info($contactmethods) {
    unset($contactmethods['aim']);
    unset($contactmethods['yim']);
    unset($contactmethods['jabber']);
    $contactmethods['facebook'] = 'Facebook';
    $contactmethods['twitter'] = 'Twitter';
    $contactmethods['linkedin'] = 'LinkedIn';

    return $contactmethods;
}
add_filter('user_contactmethods', 'extra_contact_info');

The code is pretty simple to understand. Fields that you want to remove are preceded with unset; those that you want to add are not.

Written by falcon1986

9 March, 2011 at 11:24 AM

Posted in Wordpress

Tagged with

Specify favicon for use within WordPress Dashboard

with one comment

WordPress LogoOne of my little peeves about WordPress is that a blog’s favicon disappears once you enter the WordPress Dashboard. A browser’s default behaviour upon landing on a website is to load favicon.ico from the root web directory for that website (i.e. http://www.mydomain.tld/favicon.ico), but if it is not there nothing is loaded. While dropping a favicon within the root web directory should be all that is required, sometimes specifying its location within your theme’s header.php is required to point browser’s in the right direction, but how can you do the same for the Dashboard? In this post, I will show you how you can make your favicon persistent in this location using functions.php.

Continuing with the recent posts on adding functionality to WordPress via functions.php, navigate to your theme’s files and, with a simple text editor, open the functions.php file. If one does not exist, create one and save it to your theme’s directory. Add the following lines of code and modify the domain reference to suit your setup and the location of your favicon. Save and re-enter your Dashboard to see the effects.

// Specify favicon for Dashboard
function favicon4admin() {
 echo '<link rel="Shortcut Icon" type="image/x-icon" href="http://www.mydomain.tld/favicon.ico" />';
}
add_action( 'admin_head', 'favicon4admin' );

As usual, this is a per-theme modification, so you will need to reapply if you automatically update your theme or switch to another theme.

Written by falcon1986

9 March, 2011 at 11:02 AM

Posted in Wordpress

Tagged with

Disable RSS feeds on your WordPress blog

leave a comment »

WordPress LogoDisabling RSS feeds on public blogs is not something many people do. RSS feeds allow your subscribers to easily obtain updates of your blog’s latest posts from their favourite feed reader. Visitors like great content and getting it to them in efficient manner improves your website’s popularity. So why would anyone want to disable RSS feeds? If you have a private WordPress blog with information that your subscribers should not be publishing via RSS, then disabling feeds altogether is one option. Here is how to do it with functions.php. This post does not address protecting your RSS feed.

Locate your theme’s functions.php file in a simple text editor and append with the following lines.

// Disable all RSS feeds
function disable_our_feeds() {
	wp_die( __('<strong>ERROR:</strong> We are sorry, but RSS feeds have been disabled on this website for privacy purposes. Please click <a href="http://mydomain.tld/" >this link</a> to return to the homepage.') );
}
add_action('do_feed', 'disable_our_feeds', 1);
add_action('do_feed_rdf', 'disable_our_feeds', 1);
add_action('do_feed_rss', 'disable_our_feeds', 1);
add_action('do_feed_rss2', 'disable_our_feeds', 1);
add_action('do_feed_atom', 'disable_our_feeds', 1);

Because you are editing the functions.php file, this modification needs to be applied to each WordPress theme for which disabling RSS feeds is required.

This modification does not automatically remove RSS feed links within your theme, so manually removing them from your page/post templates might be necessary if you want to be thorough.

Finally, should you prefer to retain feed access, but restrict to subscribers only, take a look at the Feed Key plugin.

Written by falcon1986

27 February, 2011 at 11:04 AM

Posted in Wordpress

Tagged with

Remove admin bar from WordPress 3.1

with 13 comments

WordPress LogoWordPress 3.1 was released last Tuesday and while it boasts a few new features, I did not want to have the Admin Bar. Now, the WordPress Admin Bar is great for quickly accessing frequently-used panels of your blog, but for a private website, I did not see much use in it. Disabling the Admin Bar is completely optional. Here I will explain how you can disable it on your own blog just by adding a few lines of code into your theme’s functions.php file.

You will only be able to implement this modification if you are using WordPress 3.1+. The Admin Bar is not present in versions 3.0.5 and below. Furthermore, the modification can only be applied to themes, so you will have to apply to new themes when they are added.

Locate the functions.php file within your theme’s subdirectory and open within a simple text editor. Append with the following code ensuring not to interfere with what is already present. Save and revisit your blog.

// Hide WordPress Admin Bar
add_filter( 'show_admin_bar', '__return_false' );

add_action( 'admin_print_scripts-profile.php', 'hide_admin_bar_prefs' );
function hide_admin_bar_prefs() { ?>
<style type="text/css">
	.show-admin-bar { display: none; }
</style>
<?php
}

The WordPress Admin Bar should now be absent both on your blog’s pages and within the dashboard. Awesome!

Written by falcon1986

27 February, 2011 at 12:09 AM

Posted in Wordpress

Tagged with

[HOW-TO] Modify WordPress’ admin e-mail address

with 5 comments

WordPress LogoIn WordPress, you can set the e-mail address that the software uses whenever it needs to send user notifications for account activation, password retrieval, etc. However, for some reason, recipients might receive e-mails from a completely different-looking address or one where the header is read as ‘WordPress’. This obviously, looks a bit sloppy. You do not want to put doubt in your subscribers’ minds when they see an e-mail coming from an address that looks suspicious. This HOW-TO will show you what you need to modify in order to fix this little annoyance. It requires that you edit your php.ini file and the core WordPress file pluggable.php.

Read more ➡

Written by falcon1986

16 April, 2010 at 8:20 PM

Posted in Wordpress

Tagged with , ,

Insert Google Calendar iFrame into WordPress page [UPDATE]

with 37 comments

WordPress LogoIn 2008, I published an article about one way in which you can go about Inserting your Google Calendar into WordPress without using a plugin. The post generated quite a bit of feedback for which I appreciated very much. Recently, I had to update the calendar on one of the websites I manage because our WordPress theme changed, so I consulted my own article for instruction. After reading through, I realized that illustrations could have been helpful, especially for those of us who need visual cues so we can verify that what we are doing is the correct thing. Therefore, this post will serve as an update to the old one and should be more helpful.

Read the rest of this entry »

Written by falcon1986

19 February, 2010 at 5:24 PM

Posted in Wordpress

Tagged with , ,

WordPress 2.8.6 – Security Release

leave a comment »

WordPress LogoIf you haven’t gotten a notification as yet, go and check your WordPress installations. This update addresses an XSS vulnerability in Press This, which I happen to be using to make this post. [Weird, isn’t it?] Anyway, since this is a security update, every WordPress user is encouraged to update/upgrade.

Read more here: WordPress 2.8.6 Security Release.

Quick Tip: Before running the automatic updater through the WordPress Dashboard, ensure that all of your current plugins are up to date. Afterward, deactivate all of your plugins and run the WordPress updater. You can re-activate your plugins after the update has been applied. Doing this will help avoid any conflicts during the update process not only when it comes to plugins, but also with the classic “Fatal error: Allowed memory size exhausted” error.

Written by falcon1986

13 November, 2009 at 11:06 PM

Posted in Wordpress

Tagged with , ,