How to Display A User Welcome Message In WordPress

Posted by Nile | Posted in Tutorials | Posted on 07-23-2010 | 2 Comments

Tags: ,

Whether you just like to put up a personal greeting or have a site that has quite a few users, something a welcome message is nice. I have seen a few people put this together and have a centralized paged where users can log in, read the personal message, and then go on their merry way using the website.

The code is really simple. This code calls the current user. If you want to only let people like contributors or other roles see the message, you have to adjust the level_0 to any of the levels corresponding with the roles. (Example: administrator is 10)


< ?php global $user_ID; if( $user_ID ) : ?>
< ?php if( current_user_can('level_0') ) : ?>

Welcome < ?php global $current_user; get_currentuserinfo(); echo ($current_user->user_login); ?>
< ?php else : ?>
< ?php endif; ?>
< ?php endif; ?>

You can edit the little welcome message to whatever you like.

Making A Two-Tiered Navigation in WordPress

Posted by Nile | Posted in Tutorials | Posted on 07-09-2010 | 0 Comments

Tags: , ,

Aside from the wonderful WordPress 3.0 navigation, a lot of people really like the two-tiered navigation. So, what is it? The two-tiered navigation is a horizontal navigation that the first layer on top is the parent pages and the second are the child pages. When you click the parent page, the child pages will appear below the parent.

In order to successfully make a similar two-tiered example like that of above, you will need to insert some html, and WordPress php functions to your layout’s template, and the CSS to help with that sheet. However, this tutorial is written for you as a step-by-step process to make it easier to understand.

Step 1. You will want to keep things simple and define our tiered navigation with its own list ID named ‘tiered-nav.’ Since this is the beginning, add the php function to call the parent page.

<ul id="tiered-nav">
<?php wp_list_pages('title_li=&depth=1'); ?>
</ul>

Step 2. After this, you want to add the php if function statement to connect the parent page and children pages, so it will connect to the correct section. For example (using the picture example included with this tutorial) if you have About, Freebies, and Contact for parent pages, you do not want to click on Contact and its child page is Site History (which is suppose to be in the About section.)

<?php if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>

Step 3. You want to make sure to add the second list that will call your child pages. To keep organized, especially when using CSS later, this list unordered list ID is named ‘sub-tiered-nav’.

<ul id="sub-tiered-nav">
<?php echo $children; ?>
</ul>

Step 4. Not done yet! You have some php functions to close. The if php statement needs to be closed and the whole function that was used in creating the two-tiered navigation needs to be closed.

<?php } else { ?>
<?php } ?>

Step 5. To get this code looking like a two-tiered navigation, you will have to specify in your CSS what to do in order to make this happen. Right now, you have two unordered lists.

/* Two Tiered Navigation */

* {
	margin:0px;
	padding:0px;
	}

/* Top Tier */

#tiered-nav {
	background:#C1DBE9;
	border-bottom:1px solid #FFFFFF;
	height:32px;
	}

#tiered-nav li {
	margin-right:25px;
	}

#tiered-nav li, #sub-tiered-nav li {
	float:left;
	list-style:none;
	}

#tiered-nav a, #tiered-nav a:visited {
	color:#FFFFFF;
	text-decoration:none;
	font-weight:bold;
	}

#tiered-nav a:hover, #tiered-nav a:active,
li.current_page_parent a,
li.current_page_parent a:visited,
#tiered-nav li.current_page_item a,
#tiered-nav li.current_page_item a:visited
        {
	background:#073447;
	}

/* Second Tier */
#sub-tiered-nav {
	background:#E3EFF7;
	border-top:2px solid #BBD8E7;
	border-bottom:2px solid #E3EFF7;
	height:28px;
	}

#sub-tiered-nav {
	border-right:1px solid #073447;
	padding:0px 7px;
	}	

#sub-tiered-nav a, #sub-tiered-nav a:visited {
	color:#073447;
	text-decoration:none;
	font-weight:bold;
	}

#sub-tiered-nav a:hover, #subnav a:active,
#sub-tiered-nav li.current_page_item a,
#sub-tiered-nav li.current_page_item a:visited {
	text-decoration:underline;
	}

Of course, you can use your own colors to pull off this effect and insert images for backgrounds.

Please sneak on over to Darren Hoyt to thank him for the original code for this tutorial.

Your WordPress Site Needs A Plugin Diet

Posted by Nile | Posted in Plugins | Posted on 06-10-2010 | 4 Comments

Tags:

Sixty plugins? What!?! Yes, I have heard some people say they use nearly sixty plugins for their website. And you know what – their site is slow!

Do you really need that many plugins?

NO.

A lot of self-hosted WordPress users are plugin happy for many reasons. Some include:

  1. This plugin does this, but this other plugin does that, so I use both.
  2. The plugin seems cool.
  3. I am not sure how to implement code snippets to my theme’s functions.php file to avoid using a plugin

What you do not know is that the plugins that use database resources can hurt you. Most webhosts allocate 25 processes per hour on data usage. If you are using more, your site might be down – unless you have your own dedicated server.

Some of these plugins, even though they seem really convenient are not needed. Some, you can turn off and turn on only when you need them. So, if you are wondering how to speed up your site, here are a few questions to consider when finally putting your site on a plugin diet:

  • Do you REALLY need it?
  • Is there a better plugin that does all of it? (You need to carefully look for alternative suggestions)
  • If given clear directions, can you copy and paste a simple code snippet into your functions.php of your theme to replace the use of a plugin?
  • Can you replace the use of a plugin by some other means? (example: HTML, CSS. PHP)
  • AGAIN: Do you REALLY need it?

Of course, if you are not sure, you can always ask. Some people might charge a little (there may be some in the WordPress Support Forum that might do it for free), but it is worth it to know what you should do with your site, rather than find out your website is down because your shared hosting account went over its allotment for data resources.

What other tips might you have for someone looking to go on a plugin diet?

WordCamp Chicago: Rocking Out Your Site With WordPress

Posted by Nile | Posted in News, WPAddict | Posted on 06-07-2010 | 1 Comment

Tags: ,

Unfortunately, during WordCamp Chicago, I was unable to access the already spotty internet available. However, that is okay. Although I am sharing it just about everywhere I know, I promised to post my Power Point presentation. In regards to it. I will be going into depth in the next few days for those who are hungry to learn more and continue to think outside the box.

Please leave me a comment if you were at WordCamp. I like to return comments or at least reply because… well, it allows me to know what other things you would like to know. I myself am eager to answer those burning questions. You are also welcome to visit Blondish.net, my main site which I talk about social media, tech (more about webmaster and user resources), web design, SEO, and even graphic design.

I appreciate how everyone has been very supportive and because there were a lot of people, I did not get to meet everyone, but my door is open. :D

Oh, and before I forget. If you like to review plugins, themes, or have WordPress related news, or even tutorials… come guest write here!

7 Tips To Being A Better WordPress Web Designer For Your Client

Posted by Nile | Posted in WordPress | Posted on 05-28-2010 | 1 Comment

Tags: ,

I having been designing exclusively for WordPress for 4 years, before that, I designed more. I am not the best in visual efforts, but I like to try to work with my clients and make sure they have a more than satisfactory product that they can use.

The problem is that I keep hearing from clients about past encounters with other WordPress designers and developers who will not go that extra step to make sure their client can efficiently use their website. In fact, they are turning to premium themes because they cannot find someone to make their project idea a reality.

Remember, WordPress is no longer a blog platform. It is a full fledge content management system that with coding and imagination, a site can become extraordinary!

Here are a few tips when stepping into designing WordPress themes:

  1. Know the code. If you are not familiar with HTML or PHP, you should not be designing as frankly, it makes other designer’s job a pain when they have to step in a correct your errors.
  2. Know WordPress. This goes for the coding, and how to use it.
  3. Design with the client’s experience in mind. Be prepared to offer them ways to use their WordPress in the easiest and more understandable way. You may need to walk them through it. Not all of your clients will be as WordPress savvy – some may not be as Internet savvy.
  4. Design logically. If you are designing for someone else and they have some coding experience, they might be a bit ticked off if your code looks terrible or you took the roundabout way to get to a solution. Streamline it. There will always be a better way to code a site. (Also, make hidden notations in the theme files case your client is familiar enough to make edits, but might not know where exactly to make them.)
  5. Be knowledgeable on site tools that will enhance the website. Whether it be an actual design or for search engine optimization, it is important to keep up-to-date on this type of news.
  6. If you do not know something, then ask around or do some research. The WordPress community is really friendly. You can either use the WordPress support forums or go to various WordPress related sites to find out.
  7. Whether it be WordPress, another CMS or static HTML, check your site in most browsers before handing it off to the client. Not everyone browses the same way as you.

Even if you are not designing for a client, you can take a lot of these suggestions with you.

What other tips can you suggest?

Creating A Simple Author Profile Page In WordPress

Posted by Nile | Posted in Tutorials | Posted on 05-17-2010 | 6 Comments

Tags: ,

I went over an effective way to put more social network handles into your WordPress profile without having to use a plugin, as well as being able to call it to your template in case you have an author’s box somewhere within your single post template.

This time, we are not going to have to tinker with your functions.php page.

To create a new page, you will need to specify that you are making a new template. This one will be called author.php

You want it styles somewhat similar to your other pages, but you can add the following and style it according to your own template. The code contains the gravatar, 3 different social network handles, and a simple listing of the author’s posts. You can customize it to display excerpts, display excerpts with thumbnails, full posts, and more.


<!-- This sets the $curauth variable -->
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
?>
<div class="post-top">
<div class="post-title">
<h2>About: <?php echo $curauth->display_name; ?></h2>
<p style="float:left;padding-right:10px;"><a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">
<?php echo get_avatar($curauth->user_email, '96', $avatar); ?>
</a></p><p style="float:left;">Connect with <?php echo $curauth->display_name; ?> at: <a href="http://twitter.com/<?php echo $curauth->twitter; ?>"><strong>Twitter</strong></a> | <a href="http://facebook.com/<?php echo $curauth->facebook; ?>"><strong>Facebook</strong></a> | <a href="http://linkedin.com/in/<?php echo $curauth->linkedin; ?>"><strong>LinkedIn</strong></a></p>
<br />
<h3><strong>Website:</strong> <span><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></span></h3>
<p><strong>Profile:</strong> <?php echo $curauth->user_description; ?><p>
</div></div>
<div class="entry">
<h3>Posts by <?php echo $curauth->display_name; ?>:</h3>
<ul>
<!-- The Loop -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?></a>
</li>
<?php endwhile; else: ?>
<p><?php _e('No posts by this author.'); ?></p>
<?php endif; ?>
<!-- End Loop -->
</ul>

In order for people to be able to see your author, simply add the following within your post’s byline:

Written by <span><?php the_author_posts_link(); ?></span>

This is actually from my own template from Blondish.net. In fact, this is what my author profile looks like at Blondish.net.

How to Optimize WordPress for Speed: Part 2

Posted by Nile | Posted in Tutorials | Posted on 05-10-2010 | 2 Comments

Tags: ,

This is a guest post by Jason Capshaw. Jason Capshaw is founder of MyWebTronics, an Atlanta web design firm. He resides in Atlanta with his wife and two children

This is Part 2 in the series of How to Optimize WordPress for Speed.

Reducing PHP functions in themes

WordPress has thousands of different functions that could be called at different points of page loading. Reducing the number of functions used by your theme will assist in speeding up page load times.

Themes are built to be used on any domain name without having to hard code anything. This is very useful for adding a new theme to your site, but it requires the use of certain functions to identify blog information. Since you know what them you are using, hard coding some of those functions will reduce server load.

Tip: the quickest way to learn how to fix something is not to back it up. So, if you are not looking for an additional lesson in programming, make sure to back up your files before you start editing them.

Here are a few functions to replace:

  • bloginfo(‘stylesheet_url’); In the head section of your site. Should replace with http://www.example.com/wp-content/themes/YOURTHEME/style.css
  • get_option(‘home’); This function is usually in the theme header in the link for your blog home page. Replace with your blog location with http://www.example.com/blog/
  • bloginfo(‘name’); This function calls your blog name. Simply replace it with your blog title, “My Example Blog” in the theme header.
  • bloginfo(‘description’); This function is usually in your header and calls your site’s tagline. Replace with your tagline.
  • bloginfo(‘template_directory’); This function (or something similar) may appear throughout the theme to call certain images the theme uses. Simply hardcode each image link to the hard URL as in http://www.example.com/wp-content/themes/YOURTHEME/images/mypic.gif.
  • edit_post_link(‘Edit this entry.’); When an editor or admin is logged in, links appears so that the site can be edited. I would just drop this all together and edit eveything from the admin panel.

Reduce HTTP requests

When a browser requests a web page, a series of communications begins between the browser and the server. Each time the servers sends a file, it sends a header first to tell the browser what to expect. If the subsequent data does not match, your browser should show an error.

The fewer times the server and browser engage the 7 different network layers of the internet, the less time will be needed to download the page. You do not want one big file with everythin in it, for example, CSS and javascript should be in seperate files. However, in an ideal situation your server should only send four different files:

  • HTML
  • Stylesheet
  • Javascript
  • Image

Most sites work like this:

  • HTML
  • Stylesheet 1
  • Stylesheet 2
  • Javascript 1
  • Javascript 2
  • Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7
  • Image 8

Steps to reduce HTTP requests:

#1 Put all CSS into one file

Some themes use multiple CSS stylesheets. Merge them together. Also, some plugins use stylesheets. If you are really serious about getting every bit of speed possible out of WordPress, you could edit the plugin and add the plugin’s CSS to your theme’s CSS file.

#2 Combine all javascript into one file

Put every single javascript function into one file. They should not conflict with each other.

#3 Use CSS sprites for background images

CSS has the ability to show only a portion of a particular image in the background. There are some problems with CSS sprites, for example ‘repeat’ may be a problem. However, many background images can be combined into one file, especially icons.

Here are a few examples of large sites that use sprites:

Stop use of Avatars

When avatars are enabled, WordPress takes the user’s email address and turns it into an md5 hash. It then communicates with Avatar to find out if the user has signed up and what Avatar they use. If they do not have one, they send the URL to the one you have selected.

The browser is required to make multiple DNS requests to the URL provided for the Avatar and download the image from a different source. This process may not be so bad for one or two comments. But when a post has many comments, it can become extremely burdensome and can slow your lightning fast WordPress load time into a turtle’s crawl.

Test plugins

When running a WordPress site, you need to weigh pros vs. cons for certain plugins. The easiest way to test a plugin, is to test your site speed before the plugin is activated, and after the plugin is activated.

If the plugin slows down your site; does it add enough value to continue it’s use? In most cases, probably not. Plugins are usually designed to get users to engage with your site, if it causes a higher bounce rate or frustrated users it is counter productive.

How to Optimize WordPress for Speed: Part 1

Posted by Nile | Posted in Tutorials | Posted on 05-09-2010 | 3 Comments

Tags: ,

This is a guest post by Jason Capshaw. Jason Capshaw is founder of MyWebTronics, an Atlanta web design firm. He resides in Atlanta with his wife and two children

There are many reasons why you want WordPress to be as fast as possible. The least of which is user experience. Visitors are extremely impatient with slow loading sites. Google has zero’d in on this fact and has now added site speed as one of its 200+ ranking factors.

Reduce data base requests

Use DB Cache to cache data base queries so that the server does not have to access the MySQL database. Database queries use up a significant portion of server resources. By only performing the database query once for multiple visitors, you free up resources to quickly download the page.

Once the plugin is activated, you will see the following at the bottom of your content if you have wp-footer() in your site:


Generated in 0.730 seconds. Made 23 queries to database and 9 cached queries. Memory used - 19.67MB
Cached by DB Cache

As you can see, it gives you a readout of how many queries were performed and how many were pulled from cache.

Optimizing your MySQL database

If you have ever used Steam for gaming, or defragged a computer hard drive, you are familiar with this concept. Basically, phpMyAdmin gives you the ability to repair corrupted data and optimize tables.

Open your phpMyAdmin panel and navigate to the database structure. Select all of the tables and select ‘Repair tables’.

Repeat the process and this time select ‘optimize’. Your MySQL database will be running at maximum capacity.

Tip: to keep from having to do this manually, you could just create a cron job and do something like this in a php file:


$sql = 'OPTIMIZE TABLE `wp_commentmeta`, `wp_comments`, `wp_links`, `wp_options`, `wp_postmeta`, `wp_posts`, `wp_terms`, `wp_term_relationships`, `wp_term_taxonomy`, `wp_usermeta`, `wp_users`';


mysql_query($sql);

Please stay tuned for Part 2 of How to Optimize WordPress for Speed.

Benefits of Using WP-SpamFree WordPress Plugin

Posted by dragonblogger | Posted in Plugins | Posted on 04-14-2010 | 4 Comments

Tags: , , , , , , , , , , ,

There are several different WordPress Plug-ins that help reduce comment spam on your blog, but one of the best ones you can find is WP-SpamFree. This plugin works differently in that you have more control over the filtering than you do with the Akismet plug-in and this plugin allows you to log all comments so you can be sure you are only catching SPAM and make sure that false positives aren’t being blocked.

WP-Spam free has an option called M2 which allows the plug-in to set cookies two ways, Javascript and Non-Javascript methods. I recommend setting it both ways as some browers (especially mobile ones) can block Javascript from running which would prevent them from leaving comments unless you have M2 check marked.

The other thing you can do is set and modify your Your current WordPress Comment Blacklist in the WP-SpamFree Options. This allows you to create a custom list of “keywords”, “emails” or IP Addresses that will automatically be blocked in the future. So if some specific IP’s or emails keep getting through your existing spam settings, you can blacklist the IP that the spam is coming from. (Use with caution as you can unintentionally block others if you put entire IP subnets or keywords that could be found on normal comments.

WP-SpamFree also comes with a built in Contact form that allows you to embed a contact for on your blog, you can customize fields and as well. It isn’t powerful or overly customizable, but can be useful if you want one plug-in that does both functions.

In my own testing I found that WP-SpamFree combined with Akismet both were an ideal way to block nearly all spam comments to your blog. Akismet alone will leave lots of comments in your Pending or Spam Bucket. WP-SpamFree will block the spam and you will never have to go weed through your pending or spam comment areas so it saves you time.

Do you use WP-SpamFree or another spam blocker? Are there any other things a site owner can do in order to reduce spam?

Caution When Downloading Free Themes

Posted by Nile | Posted in WordPress | Posted on 12-12-2009 | 2 Comments

Tags:

There are over 1,088 themes available at the WordPress Theme Directory. There are a lot more elsewhere online. Although Leland of Themelab blogs Stop Downloading WordPress Themes from Shady Sites, the point really should be: be cautious when downloading any themes ANYWHERE.

Some of the things to look for:

- Encrypted code
- Inability to edit layout to fit your own means
- Link spam that have nothing to do with your site or may be linked inappropriate websites in the footer
- Malicious code that could open your server to attacks or your own computer to viruses

“Free” is without expecting anything in return. It is great to leave a link from the original theme creator on your site so your visitors will be able to use the free theme too . However, it is a nuisance to have all the other frills, and not-so-frills. It might be difficult to accept that you could either pay for a safe theme or download a free one from a trusted source, but it is important for your internet safety and the safety of your readers. It also aleviates future problems if the layout no longer functions due to WordPress upgrades and code changes that might break or make older themes buggy. Having to hurry and fix a theme issue is not fun, and if you have a free theme from a untrustworthy site, you will be scurrying to get a new theme up.

Although not everyone has their free themes uploaded to the WordPress theme directory, if you have found a theme you like, go to the WordPress support forums or ask anyone in the WordPress community if a certain place can be trusted and can vouch for it. Like visiting any site, if you cannot trust it, why download?

Are there any sites that people should avoid?