Title: Can&#8217;t stop getting an array when using the $single function
Last modified: August 19, 2016

---

# Can’t stop getting an array when using the $single function

 *  [schneiderbw](https://wordpress.org/support/users/schneiderbw/)
 * (@schneiderbw)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/cant-stop-getting-an-array-when-using-the-single-function/)
 * I am using WordPress as my CMS and i’m trying to create a page where users can
   find a list of articles in a category. I’m basically using a modified version
   of the WP Classic theme and using the arc-cont.php file as the basis for my page
   template. I’m putting the category number that i want into a custom field and
   trying to use that as the variable. I keep getting an “Array” message when i 
   put the code in, and i can’t figure out how to get it to just list the posts 
   that i want.
 * Below is the code for the entire template.
 *     ```
       <?php
       /*
       Template Name: Archives with Content
       */
       ?>
   
       <?php
       get_header();
       ?>
   
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
   
       <div class="post" id="post-<?php the_ID(); ?>">
       	 <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
       	<div class="meta"><?php the_tags(__('Tags: '), ', ', ' — '); ?> <?php edit_post_link(__('Edit This')); ?></div>
   
       	<div class="storycontent">
       		<?php the_content(__('(more...)')); ?>
       	</div>
   
       </div>
   
       <?php endwhile; else: ?>
       <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
       <?php endif; ?>
   
       <?php posts_nav_link(' — ', __('&laquo; Older Posts'), __('Newer Posts &raquo;')); ?>
   
       </div> <// End page content, begin listing archives>
       <div id="content" class="widecolumn">
       <?php
   
             $mykey_values = get_post_custom_values( $key = 'category', $value, $single = true );
             foreach ( $mykey_values as $value ) {
             echo "$key => $value (category=$mykey_values)<br />";
                 }
   
       ?>
       <div id="main">
       <h2>Posts relating to this subject:</h2>
           <ul>
               <?php $posts = get_posts('category=$mykey_values');
   
               if( $posts ) : 
   
               foreach( $posts as $post ) : setup_postdata( $post ); ?>
   
               <li><a href="<?php the_permalink(); ?>" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
   
               <?php endforeach; ?>
   
       		<?php endif; ?>
           </ul>
       </div>
       <?php get_footer(); ?>
       ```
   

The topic ‘Can’t stop getting an array when using the $single function’ is closed
to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [single](https://wordpress.org/support/topic-tag/single/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [schneiderbw](https://wordpress.org/support/users/schneiderbw/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/cant-stop-getting-an-array-when-using-the-single-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
