Category: News


During a recent large project, I had a subcontractor who had a lot of experience with custom fields and from her I learned how to do them without a plugin. It’s actually quite easy, these are the steps you follow to add a custom field and display its contents in a WordPress template.

  • Create a custom template, upload it and apply it to a page in your site. If you upload and don’t see the template in the list in the editing page, try switching to the default theme and back, this usually will do the trick.
  • In your custom template page, you’ll need to do two things.
    • First, define the variable for the new custom field in a PHP statement.
      <?php $mycustomtext = get_post_meta($post->ID, 'mycustomtext', true); ?>
    • Then add some PHP to display the contents of the custom field if it’s in use in the page.
      <?php if (post_custom('mycustomtext')) {
      	echo '<p class="mycustomcss">' . $mycustomtext . '</p>';
      } ?>
  • Then in the WordPress page editor, under Custom Fields, click on Add New Custom Field and enter the name of the field in the left box, and the value in the right box
  • Update the page and take a look at it. You should now see your new custom field value in the page.

Dead simple, once I had to do it myself, and no need to add yet another plugin. You can create custom fields for any section of a page so that clients know where to enter what data.

I’m using a customized WordPress author template and have custom meta information for an author’s business industry within the user profile.

I want to have a page/post that will display only the authors with a similar industry meta field – like where author’s industry is equal to ‘Graphic Design,’ for instance.

I have:
<?php echo $curauth->industry; ?>

I want a page/post to show a list of all authors where ‘industry’='Graphic Design’

Does that make sense and is it possible?

This is the fourth time I’ve posted this so that Technorati will let me claim my own blog.

54r8ikhg2b

The Creative Freelancer Conference, San Diego, CA at the Omni San Diego hotel. August 26-28, 2009.

Fort Collins Internet Pros announces the 2nd Fort Collins Ignite event on Thursday August 27. Event will be held at The Drake Center in Fort Collins.

For ticket and other info click here.

For Technorati

54r8ikhg2b

© 2012 position: relative; All rights reserved. Powered by WordPress.