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'm trying to display a title, featured image, and content from a page into a new template (that will contain content from several pages). I tried to just echo the variables as shown below, but right now it's only display the content and title+"array". Any ideas?

Here is my current array:

 $id = 2131;
 $post = get_page($id);
 $content = apply_filters('the_content', $post->post_content);
 $title = $post->post_title;
 $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'single-post-    
 thumbnail' );
 echo $content;
 echo $title;
 echo $image;
share|improve this question
up vote 1 down vote accepted

wp_get_attachment_image_src returns an array, not a single value. Please refer to this article for more info: wordpress.org/Function_Reference/wp_get_attachment_image_src

Default Usage

$attachment_id = 8; // attachment ID

$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array

<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
share|improve this answer
That makes sense, but I'm confused what the syntax would look like to just return the image in an image tag from my original array? – mtthwbsh Feb 20 '13 at 1:21
@mtthwbsh Try this: echo $image[0]; – Josh Mountain Feb 20 '13 at 2:26
Worked perfect, thanks! – mtthwbsh Feb 20 '13 at 19:43

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.