Support » Fixing WordPress » Single.php 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>
    		<div class="col_6">
    		<div class="position">
    			<h1><?php the_title(); ?></h1>
    			<div class="projectinfo"><?php the_content(); ?></div>
    		<div class="clearfix"></div>
    <?php endwhile; wp_reset_postdata(); endif; ?>
Viewing 1 replies (of 1 total)
  • 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.