Title: Custom post, exclude and include
Last modified: August 19, 2016

---

# Custom post, exclude and include

 *  [mYrAn](https://wordpress.org/support/users/myran/)
 * (@myran)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/custom-post-exclude-and-include/)
 * Hi.
    Im building a site where there’s an informationbar on the rightside of the
   site on a couple of pages. Right now i have a left and a right side of the infobar,
   left holds a key e.g. Born, while right holds the value e.g. 1965. For this i
   have now made a custom value for the left bar and one for the right, and done
   this on 10 rows.. This means i have to have 20 custom values to fill 10 rows 
   which to me is very unefficient. I was snooking around the codex,
 *     ```
       <?php
   
         $custom_fields = get_post_custom(72);
         $my_custom_field = $custom_fields['my_custom_field'];
         foreach ( $my_custom_field as $key => $value )
           echo $key . " => " . $value . "<br />";
   
       ?>
       ```
   
 * and i thought that maybe you could alter the way it outputs values, and this 
   way add as many custom fields i would want without going through the hassle of
   adding 20 custom fields and if i would want more rows i would have to edit the
   theme.. This is a taste of the hell im living in right now.
 *     ```
       <div class="row">
                           	<div class="left">
                               	<?php $key="forestallning_eget1"; echo get_post_meta($post->ID, $key, true); ?>
                               </div>
                               <div class="right">
                               	<?php $key="forestallning_eget1_varde"; echo get_post_meta($post->ID, $key, true); ?>
                               </div><!-- /right -->
                           </div><!-- /row -->
                           <div class="row">
                           	<div class="left">
                               	<?php $key="forestallning_eget2"; echo get_post_meta($post->ID, $key, true); ?>
                               </div>
                               <div class="right">
                               	<?php $key="forestallning_eget2_varde"; echo get_post_meta($post->ID, $key, true); ?>
                               </div><!-- /right -->
                           </div><!-- /row -->
       ```
   
 * There’s one problem though. I have a imageslider at the top of these pages, which
   is controlled by customfields aswell. So i would need it to do this:
    For the
   slider; only get custom fields named slider, and output only the value of the
   slider field. This may be one value, or 10. For the rightside info; get anything
   not named slider, and output both key and value, enclosed in div’s. Like this:
 *     ```
       <div class="row">
       <div class="left">$key</div>
       <div class="right>$value</div>
       </div>
       ```
   
 * This would make things enormously more smooth and easy. Since i dont know php,
   im turning to the only option i know and thats the WP forum! I would be seriously
   thankful if someone would show me how to do this.. Thanks alot in advance!

Viewing 1 replies (of 1 total)

 *  Thread Starter [mYrAn](https://wordpress.org/support/users/myran/)
 * (@myran)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/custom-post-exclude-and-include/#post-1861751)
 * I found this
 * [http://wordpress.org/support/topic/need-a-plugin-or-a-way-to-exclude-a-particular-key-value-from-the_meta?replies=5](http://wordpress.org/support/topic/need-a-plugin-or-a-way-to-exclude-a-particular-key-value-from-the_meta?replies=5)
 * But now i have another problem. It doesnt output them in the right order, or 
   there is no order at all. How do i make it put them in the order i put them in?

Viewing 1 replies (of 1 total)

The topic ‘Custom post, exclude and include’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [mYrAn](https://wordpress.org/support/users/myran/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/custom-post-exclude-and-include/#post-1861751)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
