Can you help slim down my php code?
-
Hi there,
I am currently creating a site for bike tours. There are 6 different price plans and the prices are entered using custom fields.
Depending if anything is entered in the custom field I am using the following code to display it. Also if anything is entered in any of the fields I am also displaying a heading.
I can’t help feeling however it’s a little bloated with code and just wanted some advice if I can slim it down a little – with examples if you can…
Thanks For your help. Jono.
<?php if(get_post_meta($post->ID, 'gt_price-do', true) || get_post_meta($post->ID, 'gt_price-obso', true) || get_post_meta($post->ID, 'gt_price-so', true) || get_post_meta($post->ID, 'gt_price-c', true) || get_post_meta($post->ID, 'gt_price-obdo', true) || get_post_meta($post->ID, 'gt_price-obso', true)): ?> <h4>Full Tour Price:</h4> <ul> <?php if(get_post_meta($post->ID, "gt_price-do", true)): ?> <li><span class="blue">Rider with Double Occupancy</span> $<?php echo get_post_meta($post->ID, 'gt_price-do', TRUE); ?></li> <?php endif; ?> <?php if(get_post_meta($post->ID, "gt_price-so", true)): ?> <li><span class="blue">Rider with Single Occupancy</span> $<?php echo get_post_meta($post->ID, 'gt_price-so', TRUE); ?></li> <?php endif; ?> <?php if(get_post_meta($post->ID, "gt_price-c", true)): ?> <li><span class="blue">Couples Price</span> $<?php echo get_post_meta($post->ID, 'gt_price-c', TRUE); ?></li> <?php endif; ?> <?php if(get_post_meta($post->ID, "gt_price-obdo", true)): ?> <li><span class="blue">Own Bike Double Occupancy (shared room)</span> $<?php echo get_post_meta($post->ID, 'gt_price-obdo', TRUE); ?></li> <?php endif; ?> <?php if(get_post_meta($post->ID, "gt_price-obso", true)): ?> <li><span class="blue">Own Bike Single Occupancy (own room)</span> $<?php echo get_post_meta($post->ID, 'gt_price-obso', TRUE); ?></li> <?php endif; ?> </ul> <?php endif; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Can you help slim down my php code?’ is closed to new replies.