wordpress php snippets

here are a bunch of frequently used code snippets i’ve used with many of my projects

* i really should know these by now… but what are ya gonna do?

linking to the homepage

    <a href="<?php echo get_option('home'); ?>">...</a>

    image references

      <img src="<?php bloginfo('stylesheet_directory'); ?>/images/FILE_NAME.jpg"
      alt="<?php bloginfo('name'); ?>" title="<?php bloginfo('name'); ?>" />

      dynamic widgets

        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('WIDGET_NAME') ) : ?>
        <?php endif; ?>

        then, in functions.php, add this:

        register_sidebar(array('name'=>'WIDGET_NAME',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
        ));

        custom fields – mentioned before on my site, but just to have ‘em all together

          <?php $VARIABLE_NAME=get_post_meta($post->ID, "CUSTOM_FIELD_NAME", true);
          if (get_post_meta($post->ID, "CUSTOM_FIELD_NAME", true)) {
          echo ("<img src=\"FULL_PATH_TO/$VARIABLE_NAME\" />");
          } ?>

          copyright

            &copy; <?php echo date('Y'); ?> - <?php bloginfo('name'); ?>

            frequently used wordpress plugins

            i needed to keep a list of the wordpress plugins i use, either on my personal site or on the various other sites i’ve worked on

            required

            • all in one seo pack
            • google analyticator
            • google xml sitemaps
            • db cache reloaded fix
            • hyper cache

            dependent on project

            • anyvar
            • custom post limits
            • shadowbox js
            • wordpress related posts
            • contact form 7 (+really simple CAPTCHA)
            • audio player
            • my page order
            • widget entries

            i need to also put frequently-used code… nice segue, joe…

            family guy: tiegs for two

            this was an exceptionally hilarious episode: asian racism, michael j fox cracks, lord of the rings, and a spot-on street fighter reference!

            google web fonts enabled

            i’m really lovin’ the google web fonts service. i have a post about to go live on MoG soon… so i won’t gush much about it here.

            i’ve put the pacifico font as the headers and the ubuntu font as the overall body font — pretty sharp

            portlandia

            definitely gotta check out the show portlandia… it’s a sketch comedy show filmed entirely in portland, oregon. they like to make fun of the hipster, artsy type of people that inhabit pdx. plus, i’ve always liked fred armisen

            here are a few clips that made me crack up

            cell phone plans

            put a bird on it

            house sitting rules

            harajuku girls

            outdoor movies

            ordering the chicken


            * this is what it’s like to go to dinner with chaunce (ha!)

            simple technology