Archive for May, 2011

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:

        '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\" />");
          } ?>


            &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


            • 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…

            Sorry, but there aren't any posts with this date.