Hey I have a textarea in my metabox and I display the info using a shortcode. I want to output the data from that metabox as a list (each line is a list item). I used the code from here but changed it a little, because it gave me a parse/syntax error.

I need the arrays to be inside a specific div and p class, and without the explode and the code they display well (writing the html tags inside the metabox - which I don't want to do, I want just the lines of text to result the list)

My code for the shortcode is:

add_shortcode('cv', 'vp_cv');
function vp_cv($atts, $content=null) {
    'number' => 6
), $atts));
    $content = filter_shortcode($content);
global $post;
$output .= '<div class="container">';
$query = new WP_Query('post_type=resume&posts_per_page=' . $number . '&cat=' . $categories);
while($query->have_posts() ) : $query->the_post();
    $title = get_the_title();
    $projects = get_post_meta($post->ID, 'resume_projects', true);
    $projects = explode("\n", $projects);} 
         <?php for($i = 0;
         $i++){ ?>
         <li> <?php echo $project[$i]; ?></li>
            <?php } ?>

The output is:


$output .= '<div class="one-third">';

$output .= '<p class="cv-title">' . $title . '</p>';
    $output .= '<p class="cv-projects">'  . $projects . '</p></div>';       
    $output .= '</div>
<div class="clearboth"></div>';
return $output;

The title displays ok but the $projects gives me literally "Array".

Any thoughts?


You missed $output in "for" loop, wrong $project(s) name.

add_shortcode( 'cv', 'vp_cv' );
function vp_cv( $atts, $content = null ) {


    while( $query->have_posts() ) : $query->the_post();

        $title = get_the_title();
        $projects = get_post_meta($post->ID, 'resume_projects', true);

        if( $projects ) $projects = explode("\n", $projects); 

        $output .= '<p class="cv-title">' . $title . '</p>';
        $output .= '<p class="cv-projects">';
        $output .= '<ol>';

        for( $i = 0; $i < sizeof( $projects ); $i++ ) {
            $output .= '<li>' . $projects[$i] .'</li>';

        $output .= "</ol>";
        $output .= "</p>";


    return $output;

Hope it helps!

  • Great!! yeah it helps :) cant give you "useful answer" because of my low reputation for being a noobie heh. – Cynthia Lara Jul 25 '13 at 14:29
  • you're welcome, never give up : ) – iEmanuele Jul 25 '13 at 14:37
  • 1
    Now i can give you points so I came back to do so. – Cynthia Lara Oct 4 '13 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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