•  
Posts Tagged ‘php’

Succesfully running 2.8.1, but

By Austin On July 12, 2009 1 Comment

I’ve updated the site to the latest release of WordPress. 2.8.1 fixes many bug found in 2.8 and I finally was ready for the update. While everything went smoothly, I did have to update my theme a bit to run some of the additional widget area.

Using the old style dynamic_sidebar( 'Utility: Header' ); didn’t work any more, while just replacing the Title of the widget area with the ID fixed this problem: dynamic_sidebar( 'utilityheader' );.

I also came across a major error with one of my plugins. AsideShop just doesn’t work with and version WordPress

Click here to continue reading


Calling custom fields for next/previous posts

By Austin On June 10, 2009 1 Comment

Custom

Click here to continue reading


Simple double listed columns

By Austin On May 20, 2009 No Comments

I’ve been asked before on how to display categories in multiple columns. Well, WPRecipes has posted a code snippet for this Click here to continue reading



Remove spaces when echoing the_title

By Austin On May 15, 2009 4 Comments

Ever

Click here to continue reading


Adding a external file after the first post

By Austin On April 9, 2009 No Comments

How might you display a Google ad after the first post or anything you like? It is very simple. You just need to add the variable $loopcounter in the Loop. If the $loopcounter is less than or equal to 1, then include your option. Check out the code:

<?php if (have_posts()) : while (have_posts()) : the_post(); $loopcounter++; ?> // your loop <?php if ($loopcounter <= 1) { include (STYLESHEETPATH . '/you-file.php'); } ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?>

Pretty simple huh. Well in the $loopcounter line, you may change the include to point to any file or maybe

Click here to continue reading


A simple way to query posts

By Austin On April 6, 2009 No Comments

Here is a simple way to call query_posts with an array of options. For all options you my use visit: WordPress Codex.

<?php $my_query = array('showposts' => 4, 'post__not_in' => $do_not_duplicate); ?> <?php query_posts($my_query); ?> Click here to continue reading


How to: Add any authors gravatar to their post

By Austin On February 4, 2009 No Comments

This is an easy one, just add one line to your single.php file where you would like the Gravatar to show up.

<?php echo get_avatar( get_the_author_id(), $size = '96', $default = '<path_to_url>' ); ?> Click here to continue reading


Limit the characters that display on the_title

By Austin On January 19, 2009 2 Comments

Ever wanted to display the title of a post somewhere but limit the amount of characters that are shown? For instance, this post has a very long title, and if I were to use <?php echo the_title() ?> it would show as follows: Limit the characters that display on the_title.

That may not fit well on one line in lets say a widget or small width div. So here is a neat trick you can use:

<?php $title = the_title('','',FALSE); echo substr($title, 0, 11); ?>

Pretty simple huh, just note the bold numbers, in this case 11 character would output like this: Limit

Click here to continue reading


Display custom url if comment authors url is blank

By Austin On January 15, 2009 1 Comment

Here is a nifty trick for your comments.php template. If someone comes to your site and leaves a comment but doesn’t leave a url back to there site, the default link that is shown in place of the php code comment_author_url is the current page link.

That might not look good. So, here is a little trick that I just implemented into my site. Besides installing the twittar plugin and pulling Twitter avatars I wanted to use the image itself for the authors url like. But if the author doesn’t have a Twitter avatar or a Gravatar it will display a

Click here to continue reading


Echo custom fields in any category

By Austin On January 11, 2009 2 Comments

Here is a neat trick. Say you want to show a custom field in you post or in a certain categories post. There is a simple code you need to write in order to accomplish this:

<?php $image = get_post_meta($post->ID, "image", $single = true); ?> <?php if($image != '') : if(in_category(7)) { echo ''; } else { ?> <img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a>

In the example above I am calling the variable $image and telling the server that it equals the value of “image” inside get_post_meta or “custom field” of the current post.

Then we are asking if that variable $image

Click here to continue reading