I wish to output a string from an array in PHP

I’ve got a plugin for WordPress that lets you reorder posts. This plugin displays the post_name and is surrounded by a drag n’ drop box.

I wish to change the format of the

Read More

“post_name”

to

“post_name – custom field”

I have tried changing the PHP to the following:

    $output .= $indent . '<li id="item_'.$page->ID.'"><span>'.apply_filters( 'the_title',
    $page->post_title, get_post_meta($post->ID,'item_',TRUE), $get_post_meta[0],
 $current_customfield = $page->$customfield ) . ' - ' .$current_customfield.

but the “current_sutomfield” displays as an array (ie; just “ARRAY”). So I changed it to the following (added print_r):

    $output .= $indent . '<li id="item_'.$page->ID.'"><span>'.apply_filters( 'the_title',
    $page->post_title, get_post_meta($post->ID,'item_',TRUE), $get_post_meta[0],
 $current_customfield = $page->$customfield ) . ' - ' .print_r($current_customfield).

but this outputs the whole post metadata (including “Array =>”) so I stopped going down that route.

I can see the author of the plugin has just made “item_” serialised. What would be the best way to display my $customfield serialised? I know I’m missing something really obvious but it’s been racking my brains as to why I can’t get a simple line to output.

Thanks.

Related posts

Leave a Reply

1 comment

  1. I don’t know what $current_customfield contains, but obviously it is an array; either pick one of the array entries like $current_customfield[0], or use explode(' / ', $current_customfield).