Title: Custom Fields formatting
Last modified: August 21, 2016

---

# Custom Fields formatting

 *  Resolved [mickwarnes](https://wordpress.org/support/users/mickwarnes/)
 * (@mickwarnes)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-formatting/)
 * I am using Custom Fields to eventually allow other users to put in consistent
   information on to members pages, which I have done. By default the Field and 
   the Value show inline with a space between them, but I would like all the Values
   to line up, justified to the left. A bit like if you had a two column table with
   all the Fields in the left hand column and the Values in the right but justified
   left to their cells.
    I understand CSS to a degree, but not enough to get this
   to work. I look forward to some assistance Thanks Mick

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-formatting/#post-5044318)
 * If it can be done with CSS, a link to the site where it can be seen might allow
   someone to help.
 * It may require modifying the code that displays the Custom Fields. Can you post
   a dozen or so lines of that code?
 *  Thread Starter [mickwarnes](https://wordpress.org/support/users/mickwarnes/)
 * (@mickwarnes)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-formatting/#post-5044325)
 * The URL for where I currently am is [http://hwww.hertsvolleyball.co.uk/hva/teams/local-teams/harriers-st-albans/](http://hwww.hertsvolleyball.co.uk/hva/teams/local-teams/harriers-st-albans/)
   
   I have changed the meta to replace the unordered list for a <span> in post-template.
   php
 *     ```
       function the_meta() {
       	global $id;
   
       	if ( $keys = get_post_custom_keys() ) {
       		echo "<span class='post-meta'>n";
       		foreach ( $keys as $key ) {
       			$keyt = trim($key);
       			if ( '_' == $keyt{0} )
       				continue;
       			$values = array_map('trim', get_post_custom_values($key));
       			$value = implode($values,', ');
       			echo "<span class='post-meta-key'>$key:</span> <span class='post-meta-value'>$value</span></br>n";
       		}
       		echo "n";
       	}
       }
       ```
   
 * in style.css I currently have the following to format the custom fields, which
   I know isn’t right, but I have run out of ideas.
 *     ```
       .post-meta-value {color: blue; left:400px; width:400px;}
       .post-meta-key {font-weight: bold; font-size: 110%;  width:200px;}
       ```
   
 * I have been experimenting with absolute and relative positioning and just can’t
   seem to get it right.
    Thanks
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-formatting/#post-5044329)
 * Try this for your function:
 *     ```
       function the_meta() {
       	global $id;
   
       	if ( $keys = get_post_custom_keys() ) {
       		echo "<div class='post-meta-table'>\n";
       		foreach ( $keys as $key ) {
       			$keyt = trim($key);
       			if ( '_' == $keyt{0} )
       				continue;
       			$values = array_map('trim', get_post_custom_values($key));
       			$value = implode($values,', ');
       			echo "<div class='post-meta-row'><div class='post-meta-key'>$key:</div><div class='post-meta-value'>$value</div></div>\n";
       		}
       		echo "</div>\n";
       	}
       }
       ```
   
 * And this for your CSS:
 *     ```
       .post-meta-table { display: table; }
       .post-meta-row {
          display: table-row;
       }
       .post-meta-key,
       .post-meta-value {
          display: table-cell;
          padding: 0 0 10px;
       }
       .post-meta-key {
          font-size: 110%;
          font-weight: bold;
          width: 200px;
       }
       .post-meta-value {
          color: blue;
          text-align: left;
          width: 400px;
       }
       ```
   
 *  Thread Starter [mickwarnes](https://wordpress.org/support/users/mickwarnes/)
 * (@mickwarnes)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-formatting/#post-5044335)
 * Thanks vtxyzzy
    That has worked perfectly. I was almost there using floats and
   hadn’t thought about using tables. Cheers Mick

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Fields formatting’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [mickwarnes](https://wordpress.org/support/users/mickwarnes/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-formatting/#post-5044335)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
