• For people who work with Costume fields more than categories, this code will solve your time easy way :
    Her in this example i set a field :
    home-type
    with 3 keys :
    Apart, Villa, Cottage.

    And then, create your 3 single page for each key,

    after, open the single.php remove all the code, and copy past this code, and save:

    <?php $value = get_post_meta($post->ID, 'home_type', true);
    	if($value == 'apart') {
    		include (TEMPLATEPATH . '/single-apart.php');
    	} elseif($value == 'villa') {
    		include (TEMPLATEPATH . '/single-villa.php');
    	} elseif($value == 'cottage') {
    		include (TEMPLATEPATH . '/single-cottage.php');
    	} else {
    		include (TEMPLATEPATH . '/single-default.php');
    	}
    ?>

    In every post you publish, select one of the keys (costume field you had created), and then publish your work,

    the code will check in the post you explore if it contain some of the keys, if not it will show the single-default.php

    Hop it will help some one.

    Good luck

  • The topic ‘Trick : Show different single pages, for different products, using custom fields’ is closed to new replies.