Posts Tagged ‘wordpress’

WordPress – Featured Articles with Excerpt and Read More Link

Saturday, August 15th, 2009

I’ve been rather busy lately, mostly with web work, so I’ve been manipulating the WordPress template tags with increasing frequency. I often come across an issue that I can’t find the answer to as quick as I like, or in this case at all, so I’m sharing my little code developments with you. It is rather simple, and highly customizable, so use and update it to your heart’s content.

The below code creates, in WordPress, an unordered list of the 5 most recent posted items with your custom crafted excerpt followed by a read more link which can be changed as desired:

<h3>Recent Articles</h3>
        <ul><?php $postslist = get_posts('numberposts=5&order=DESC&orderby=date');
 		foreach ($postslist as $post) : 
 		?>
   	<li><a href="<?php the_permalink(); ?>">
              <?php the_title(); ?></a> - <?php the_excerpt(); ?> <a href="<?php the_permalink(); ?>" class="more">More &gt;&gt;</a>
        </li>
	<?php endforeach; ?>
    	</ul>

Here we have the same general code, but with this the there is a specific category it is pulling from, so you would change the “category=3″ to your category’s id number:

<h3>Featured Articles</h3>
        <ul><?php $postslist = get_posts('numberposts=5&order=DESC&orderby=date&category=3');
 		foreach ($postslist as $post) : 
 		?>
   		<li><a href="<?php the_permalink(); ?>">
                      <?php the_title(); ?></a> - <?php the_excerpt(); ?> <a href="<?php the_permalink(); ?> "class="more">More &gt;&gt;</a></li>
		      <?php endforeach; ?>
    	</ul>

If you just want it to pull the first 55 characters from your entry, instead of a custom made excerpt, use the following:

<h3>Featured Articles</h3>
        <ul><?php $postslist = get_posts('numberposts=5&order=DESC&orderby=date&category=3');
 		foreach ($postslist as $post) : 
 		?>
   		<li><a href="<?php the_permalink(); ?>">
                      <?php the_title(); ?></a> - <?php the_content('<span class="more">More &gt;&gt;</span>'); ?></li>
		      <?php endforeach; ?>
    	</ul>

So, hopefully you WordPress users out there will find this useful. I’ll post a link to the site I’m currently using this on as an example, once the site is ready for public viewing.

Don’t Forget to Check the Checklist

Saturday, April 25th, 2009

Even if you are making a theme for your own use, make sure you follow the theme development check list over on the WordPress Codex.

I’m working on revamping my portfolio section, and in the extensive troubleshooting process I came across a nice little plugin for Slimbox2. Which just like everything else I tried, failed to work. They appeared to have a nice little support forum so I posted my query and after much trial and error with the plugins creator (oddly enough I went to high school with his brother), I discovered the issue was with my theme.

I poked around and discovered that I was missing a small bit of quite important code for plugins to work:
< ?php wp_head(); ?>

This little line of code is essential for WordPress and its plugins to know where to add elements to the header.

With that mystery solved, expect a better portfolio section soon.

For an example of what the Slimbox2 plugin does, view this post of mine on the iPod case I made, and click on the image.

Andreas Tabor’s Aesthetic Literacy

Tuesday, April 21st, 2009

I recently began a collaborative effort with a friend of mine, Andreas Tabor, redesigning his existing online portfolio, AestheticLiteracy.com.  Andreas is in the last few weeks of his undergraduate career as a graphic design student and needed a site that expressed his personality but was also easy to keep up to date.

We discussed his his options and it seemed that a custom WordPress theme with some instruction on maintaining his final site would be enough to meet all his needs. Andreas provided me with his desired aesthetics and layout as a Photoshop file which I then converted into code and implemented as a WordPress theme.

This was a unique experience for me as I was acting more in the role of a code monkey with less design power.  It was also a good learning opportunity as I was forced to think a bit differently than if I had created the layout from scratch.  Overall, working with a friend was a challenge, but I’m glad I could help him out while also gaining more knowledge and experience with the capabilities of WordPress.

Slow Loading

Saturday, April 11th, 2009

I’ve been helping a friend of mine in the redesign of his web presence, well, less on the design end and more with development.  Today he came to me with a grave issue, his site was slower than molasses.  In the vast world of the Internet, nothing is worse than a slow loading website.

Both my site and his new site are powered by WordPress, so I instantly checked mine to see if it was an overall WordPress issue. When it wasn’t, I immediately blamed his hosting provider, but thought better of it once I checked a static page on his site.  I then recalled that we were using some javascript to make his portfolio section nicer, but that shouldn’t have slowed the admin section as well.  Just to be safe, I removed it.  Nothing happened, so I set it up just so it would be served up on the portfolio page, not all sections of the site.

So to resolve this issue, I set off to my trusty Google search.  The majority of talk on the web about slow WordPress mentioned version 2.6 and/or faulty plugins.  Since both our sites are above 2.6, I deactivated all plugins, but nothing happened.  Now, I was just puzzled.

Then I remembered that I had added some code to my site’s htaccess file to optimize loading using GZIP compression.  Following the instructions on BetterExplained, I brought the load time down from 19.74 seconds to 2.9 seconds. This little trick should work for speeding up your site’s load time in all modern browsers.

Other resources for checking and increasing site speed:

Pingdom.com’s speed test

Yahoo’s Best Practices for Speeding Up Your Web Site

Yahoo’s YSlow add-on for Firebug in Firefox

Vladimir Prelovac’s WordPress Optimization Bible

Important Consideration: When ever troubleshooting any issues with a site’s speed check out the host’s official status, for example DreamHost’s status page or HostGator’s Twitter. Make sure to keep your own service’s status handy, it can be invaluable!

Time to Hit the Polls

Monday, April 6th, 2009

Recently I posted how I was entering the Best WordPress Design Award for the Retro/Vintage look, and it seems I have been shortlisted.

So, if you like the look of my site please go vote for me, the Best Retro & Vintage category is the last one posted:

Best WordPress Design Awards Time to-Vote

Thanks for the vote, and also just thanks for reading!

 Page 1 of 2  1  2 »