Wednesday, December 9, 2009

Wordpress show make model & price

Wordpress is a great CMS system but it is a little tricky to display any custom Fields. Displayed below is the code needed to be added to the archives list so that it will preview the make model and price of your items. Of course you need to create the custom fields and fill them in for each item in order for this code to work. Another trick is to add a link to the item itself when you click on the tag. To do that you need to add your own 'a href' and then strip the code off the 'get_the_tags' response.

< a href="< ?php the_permalink() 
?>"> <?php echo strip_tags(get_the_tag_list
('Item: ', ', ')); > </a>
< ?php $key="Price"; if 
(get_post_meta($post->ID, $key, true)!="") 
echo "Price: ".get_post_meta($post->ID, $key, true); ?>
< ?php $key="Make"; if 
(get_post_meta($post->ID, $key, true)!="") 
echo " Make: ".get_post_meta($post->ID, $key, true); ?> 
< ?php $key="Model"; if 
(get_post_meta($post->ID, $key, true)!="") 
echo " Model: ".get_post_meta($post->ID, $key, true); ?>  
Post a Comment