WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get a custom post value from post ID

PHP code :

$custom_field = get_post_meta(2055, the_field('titdesc'));

Output :

array(6) {
  array(1) {
    string(1) "1"
  array(1) {
    string(12) "1373450528:1"
  array(1) {
    string(8) "work.php"
  array(1) {
    string(34) "and some experience, coffee & fun."
  array(1) {
    string(19) "field_51baf57155c20"
  array(1) {
    string(0) ""

I want ["titdesc"] value but not able to get what to write in PHP to get ["titdesc"]'s value.

share|improve this question
As a note, you should be using get_field() instead of the_field(). – RRikesh Jul 10 '13 at 11:53

I think you messed up a bit. I'm assuming you're using the ACF plugin because you used the_field().

Have you tried only the_field('titdesc'); if you're in the WordPress loop? Those functions already query values stored in your postmeta table. I'm assuming you have a field called titdesc since you're trying to read it using the_field('titdesc').

If you're not in the loop, you must pass the post ID too, like the_field('titdesc', 2055);.

From what I've noticed, ACF uses two rows per custom field. For you it is:

  • titdesc => and some experience, coffee & fun.
  • _titdesc => field_51baf57155c20

The first pair of values stores the field name titdesc and the field value and some experience, coffee & fun. and the second pair of values is a reference to the field name's unique ID, which is field_51baf57155c20 here.

As a note, get_field() will return a value and the_field() will echo the value.'

If you want to pass the value in a function, you should use get_field() instead. What you got in your var_dump() output is all meta values stored for that particular post ID.

share|improve this answer

You should use

echo "<pre>";
print_r($array_name); //$custom_field in your case
echo "</pre>";

That generates a more understandable array dump.


 echo $custom_field['titdesc'][0];

would do in your case.

or you can directly get a single meta key using

$titdesc = get_post_meta(2055, 'titdesc',true);
echo $titdesc;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.