May 26, 2010

New wordpress theme and php

My new WordPress theme is up. So if you’re reading by RSS, I do hope you come see my work in progress thus far.

I didn’t accomplish all I wanted to but I figure that since the general look and feel is there, I’d go ahead and go live with it. I’ll still be doing mostly back end work and maybe tweaking the fonts a little bit.

My portfolio section, while not the best looking, does now have it’s own dedicated spot. I need to update it with all my recent projects. I’ve really put off on putting projects on there.

I wanted to point a post written at CSS-tricks about server side programming language of choice. I am proud about the remarkable number of people that are using PHP. I personally love PHP since I first started dabbling in it. It’s easy to learn, it’s still being developed and I think eventually, it’ll be one of the languages most preferred by developers.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 24, 2010

WordPress theme progress

Spent most of the weekend working on my new theme. A fair amount of JavaScript but nothing compared to the ton of Photoshop. I’m picky I guess, when it comes to fonts.

I’ll probably be done within in a few days. I built an archive page, finished styling the blog posts. Still need to customize the commenting styles though I don’t see that taking too much time / customization. I think I’ve allocated more time to the design rather than the functionality. Functionality is really second nature to me when it comes to WordPress and really, if you don’t know, you can probably find it on google.

I’m going to work on building the portfolio section. I’ll be using the post thumbnails and it’ll have a gallery sort of feel to it. Then when the user clicks on a thumbnail, I’m hoping to have an overlay with a larger image and a description of the project plus a link to the live site.

Other than that, allergies have been killing me. Later tonight (or sometime this week), I’ll have a post about a cool way to do rollover images.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 21, 2010

Feeling motivated about WordPress

Working on a new blog theme. The free themes that I’ve been using have been great but I really need some more levels of customizations. Some of my goals for this is to incorporate/improve features of plug-ins I consistently use.

Here are some upfront ideas for my next blog layout:

  • A flickr flipper – basically something calling my Flickr feed to display my images. With user-controlled navigation, they can browse my Flickr images with next/previous links. The browsing of pictures would be seamless with no page refresh, just calling everything with jQuery. I’ve already built out this component.
  • “Latest box” to show the latest post in each category. Often times, I go on writing sprees where I spent a week talking about just one topic but I want a better way of displaying my other posts so that when users come to the page, it’s not full of WordPress or full of shooting. I want them to see EVERYTHING I have to say. The homepage should give a user the overall idea of the things I enjoy talking about.
  • Implement a better method of viewing my coding examples with a jQuery method of an expanding box. This also means that the content section shouldn’t feel closed off so that when the box expands, the overall design will not be disrupted.
  • Build out a separate portfolio area that is still powered by WordPress but isn’t incorporated with my other blog posts. This really has been something I needed for a long time but never got around to.

I’ve needed to build out a custom theme for myself for a long time but since I’m a web producer/developer for the most part during my day job, I’ve felt burnt out. However, I also think that I should have a place to showcase my web development skills, along with having a theme that makes me enjoy writing. Because let me be honest, tradition blog flow is kind of boring.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 20, 2010

WordPress: Limiting number of categories displayed on post

Thanks to swiftthemes.com, this function came in handy when I had to modify the way categories were being called in the fitness blog. :) Just add the following snippet into your functions.php file.

function swift_list_cats($num){
	$temp=get_the_category();
	$count=count($temp);// Getting the total number of categories the post is filed in.
	for($i=0;$i<$num&&$i<$count;$i++){
		//Formatting our output.
		$cat_string.='<a href="'.get_category_link( $temp[$i]-&gt;cat_ID  ).'">'.$temp[$i]-&gt;cat_name.'</a>';
		if($i!=$num-1&amp;&amp;$i+1&lt;$count)
		//Adding a ',' if it's not the last category.
		//You can add your own separator here.
		$cat_string.=', ';
	}
	echo $cat_string;
}

Then call your categories by using this snippet where 3 is the number of categories you want to display

< ?php swift_list_cats(3); ?>
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 19, 2010

Fake it till you make it

I really know what it feels like needing to know something that you just haven’t learned yet. Trust me, I know. I’ve been in those shoes and it’s just a bad feeling admitting you don’t know. You’d rather fake it till you make it i.e. pretend to know/show confidence that you can make it happen while you figure out just how to do it. I’ve done that before at previous jobs. There is some pointers I would like to make about this philosophy though.

I’ve been doing a lot dealing with WordPress (hence the flow of my recent WordPress related entries). However, the guy actually in charge of blogs isn’t really in the know about WordPress (which is why I’m the one building the themes and everything). He doesn’ t know much about PHP or MySQL or CSS…

So someone asked him if he could put in the post thumbnails into the archive pages for the categories, authors, etc. Instead of asking me “hey, how do you do this?”, they told the person “I would love to but it’s really hard…”

It really makes the situation look bad if you say “That’s too hard to do” and when they ask someone else, they do it in 10 seconds. Really bad.

Fake it till you make it. However, while you’re faking, be sure you’re learning along the way and not trying to scrape by because you haven’t learned something. I’m generally considerate about what to speak up about and try to word things so that the not-knowledgeable person won’t feel like I’m stepping on toes.

But really, if there’s something that you don’t know how to do, you can really ask me. I’m not going to humiliate you in front of coworkers because you don’t know how to do something. I’ll show you. I’ll teach you. I’ll be nice. No, I don’t bite.

I say this to the person/people who don’t read my blog.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 17, 2010

WordPress: php in widgets

I never saw the point of being able to execute PHP inside of widgets until the whole “Lets try to use existing functionality in WordPress” came around. So I wasn’t allowed to build 92819238 custom widgets. I couldn’t really “hard code” anything into the widget unless it was easy to edit via the admin panel. Long story short, if it took too much time to build something custom, find a way to use what’s already there.

This is where I found Exec-PHP. It allowed me to use WP template tags inside my widgets.

Two thumbs up here. :)

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 14, 2010

Building an authors’ page on WordPress

So one of my recent tasks at work was to build a page in WordPress that is listing all the authors and giving a short biography. Since we’re trying to utilize all of the WordPress functions, I decided it’d be best to make a dynamic page using a custom template.

First thing you need to do is fill out the biography on all the authors as shown below:

Next thing, create your template page. Lets go through this step by step:

First you need to define your template:

< ?php get_header();
/*
Template Name: MilBloggers
*/
?>

Next you want to create a query to your wordpress database and get the authors’ information:

< ?php 
//query to get authors
$query = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename"; 
$author_ids = $wpdb->get_results($query);
 
// Loop through each author
foreach($author_ids as $author) :
 
	// Get user data
	$curauth = get_userdata($author->ID);
 
	if($curauth->user_level == 1) : //since there were other users, I only wanted the bloggers and not everyone else
		// Get link to author page
		$user_link = get_author_posts_url($curauth->ID);
 
 
?>

Now it’s time to display the information:

<!-- author's name -->
<h2><a href="<?php echo $user_link; ?>" title="< ?php echo $curauth->display_name; ?>">< ?php echo $curauth->display_name; ?></a></h2>
 
<!-- author's description -->
< ?php echo $curauth->description; ?>

Lastly, close out your if statement and your foreach loop:

< ?php endif; ?>
< ?php endforeach; ?>

Last thing you want to do is create a new page in WordPress and change the template it’s using to the template you made:

This is what my final product looked like after I did all the css and formatting:

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 12, 2010

Targeting first blog entry in WordPress

In a recent project, there was need to customize the first entry of WordPress without those customizations carrying throughout the rest of the entries. I achieved this by setting up a counter. When the counter was equal to 1 (1 being the first entry), I will apply my styles there.

You want to find the start of your loop which looks somewhat like this:

< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>

This is where you want to add a counter. You want to make this loop look something like this:

$count = 0;
< ?php if (have_posts()) : while (have_posts()) : the_post(); $count++; if ($count == 1) ?>

As you can see, you still have your basic loop. Before the loop, you set your $count to zero since it increases at the beginning of the loop, you want your first loop to be loop one. Inside your loop, $count++ is what increases your loop interval. Following that, a condition if statement checks to see when $count is equal to one.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 11, 2010

Using WordPress Bio

So like in my previous entry, I wasn’t aware that WordPress author’s description had stripped the html from the source. I don’t know why it worked perfectly for me and not for anyone else. However, I found a plugin to work as a solution. Yay for existing functionality with a little minor tweak!

Weasel’s HTML Bio

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

May 10, 2010

WordPress: Author’s Bio Description

There are those that will say “Don’t customize it too much. If the functionality is there, use that and not try to ‘reinvent’ the wheel.”

I’m all for NOT reinventing things. Most times I don’t. I’m fine with using pre-existing functionality in WordPress.

Recently, someone told me that you couldn’t create links in your user bio (which you can call on your theme with a WordPress template tag). I tested it out myself because I’m pretty sure I’ve seen more than a dozen people link from the author’s bio.

It works.

“You can only have one link though. No target blank. Nothing else.”

I left my existing link alone, added a new one and added “target=”_blank” to the new link.

It works.

“I’ll deal with it when I’m done pushing content.”

What is there to deal with? The fact that there is no need for a workaround?

It’s not even so much that the person is trying to customize this aspect, it’s the fact that he told me to use existing functionality. I would think directions given would be followed by the one that gave the directions?

Oh well.

Moral of the story: you can create links in your author’s biography and it can be set to pop up in a new window. And all that jazz. You can have a workaround if you want, but there’s no real need if you want to keep it simple.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon