Title: Single.php id calling
Last modified: August 21, 2016

---

# Single.php id calling

 *  [Dvd709](https://wordpress.org/support/users/dvd709/)
 * (@dvd709)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/singlephp-id-calling/)
 * Hi guys,
 * So I created a gallery(custom) and well when you click on one of the images(that
   would be archive.php), which then redirects you to single.php(with information
   of the picture and itself).
 * Now what I can’t figure out is when you’d create an array and you’d need to fill
   in ‘page_id’ in the args now what I don’t get is when you click different images
   you get different id’s, what would I need to fill in the args? Here an example
   of what i’m trying to do:
 *     ```
       <?php $args = array(
       		'page_id' => '',
               'posts_per_page' => 1
             );
             $query = new WP_Query( $args );
             if ( $query->have_posts()) :
               while ( $query->have_posts()) :  $query->the_post(); ?>
   
       <div id="paginawrap">
       	<div class="pagina">
       			<div class="clearfix"></div>
       		<div class="col_3">
       		<div class="thumbs"><?php if ( has_post_thumbnail() ){the_post_thumbnail('thumbnail');} ?></div>
       			<h3></h3>
       				<p></p>
       		</div>
       		<div class="col_6">
       		<div class="position">
       			<h1><?php the_title(); ?></h1>
       			<div class="projectinfo"><?php the_content(); ?></div>
       		</div>
       		<div class="clearfix"></div>
       	</div>
       </div>
   
       <?php endwhile; wp_reset_postdata(); endif; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [Sleneau](https://wordpress.org/support/users/sleneau/)
 * (@sleneau)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/singlephp-id-calling/#post-4510617)
 * You get different ids because when you iterate through a loop, wordpress uses
   that same code over and over on a list of different posts that match the query
   parameters you sent to the database. Each time wordpress loops through the loop,
   it uses a new set of information to fill out the template, and add a new blog
   post, or image in your case. This is important if you want each post to have 
   the right information.
 * Other than the confusion, was there something malfunctioning with the query you
   posted?

Viewing 1 replies (of 1 total)

The topic ‘Single.php id calling’ is closed to new replies.

## Tags

 * [args](https://wordpress.org/support/topic-tag/args/)
 * [array](https://wordpress.org/support/topic-tag/array/)
 * [custom gallery](https://wordpress.org/support/topic-tag/custom-gallery/)
 * [page_id](https://wordpress.org/support/topic-tag/page_id/)
 * [single.php](https://wordpress.org/support/topic-tag/single-php/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Sleneau](https://wordpress.org/support/users/sleneau/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/singlephp-id-calling/#post-4510617)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
