Title: get_post_custom
Last modified: August 19, 2016

---

# get_post_custom

 *  Resolved [frmars](https://wordpress.org/support/users/frmars/)
 * (@frmars)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/get_post_custom/)
 * Hello again
 * On some homepage items of my theme, the publisher will be able to change the 
   background colour of the div to make the info stand out.
 * To achieve this, I created a custom field for the posts named “change_colour”.
 * In the loop, I test the custom field, which is **either empty or contains the
   word “black”**:
 *     ```
       <?php [bla bla] the_post();
   
       $MAMA = get_post_custom();
       $DADA = $MAMA['change_colour'];
       if ($DADA='black'):
       [ CSS CHANGE ] ; [endif etc]
       ```
   
 * Hmm. My PHP works but results are not as expected. Everything turns black. Doesn’t
   work.
 * I php-[echo]ed the variable to check: it just says “Array”.
 * Damn. What am I missing ?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/get_post_custom/#post-1386355)
 * Try using something like:
 *     ```
       <?php $color = get_post_meta($post->ID, 'change_colour', true);
       if( $color == 'black' ) :
       [CSS CHANGE]
       endif;?>
       ```
   
 * [http://codex.wordpress.org/Function_Reference/get_post_meta](http://codex.wordpress.org/Function_Reference/get_post_meta)
 *  Thread Starter [frmars](https://wordpress.org/support/users/frmars/)
 * (@frmars)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/get_post_custom/#post-1386436)
 * Thanks. It did the job nicely.
 * However, may I say the codex on that matter is far too vague and far too unclear
   for a non specialist like me.
 * **Compare :**
 * **• [get_post_custom](http://codex.wordpress.org/Function_Reference/get_post_custom):**
   _«
   returns a multidimensional array with all custom fields of a particular post 
   or page »_ **• [get_post_meta](http://codex.wordpress.org/Function_Reference/get_post_meta):**_«
   returns the values of the custom fields with the specified key from the specified
   post.»_
 * I don’t know if WordPress has a commercial branch and uses the tremendous success
   of the free software to make business (and if it’s not, it should), but after
   browsing through the codex for a few days/weeks now, it could definitely be made
   simpler AND/OR more complete, to appeal to the larger number.
 * Why not hire a written communication debugger and planner ? I am free for hire!
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/get_post_custom/#post-1386492)
 * WordPress commercial activities don’t extend beyond some aspects of wordpress.
   com and automattic.com. Generally it’s based open open source, community-developed
   tools and resources.
 * If you could help with the Codex and you’d be willing to volunteer a little time,
   I’m sure your experience would be more than welcome. There is a [Documentation mailing list](http://codex.wordpress.org/Mailing_Lists#Documentation)
   that you might be interested in. Other than that, all it takes is to [create a Codex account](http://codex.wordpress.org/index.php?title=Special:UserLogin&returnto=Mailing_Lists),
   read through the Wiki documentation and join in.

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

The topic ‘get_post_custom’ is closed to new replies.

## Tags

 * [get_post_custom](https://wordpress.org/support/topic-tag/get_post_custom/)
 * [postmeta](https://wordpress.org/support/topic-tag/postmeta/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/get_post_custom/#post-1386492)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
