Always the same post of a custom post type is shown on a single page
-
Hi i ran into an odd problem. I am running WordPress 3.8 and the relevant plugins are advanced custom fields (including the repeater field add on) and custom post types ui. I’ve created a custom field for projects and display them in a custom post type.
The custom field consists of:
1) title
2) Project summary picture (fieldname: pro_preview, field type: image)
3)Project description (fieldname: pro_description, field type: text area)
4) project services (fieldname: pro_services field type: repeater)
4.1) service (fieldnamen: pro_service_single field type: text)
5.) project images (fieldname: pro_images, field type: repeater)
5.1.) image (fieldname: pro_impressions, field type: image)I have an overview page (template-projects.php) which lists all projects properly. If i mouse over one of the projects (e.g. running) the href shows localhost:8888/testsite/projects/running, or localhost:8888/testsite/projects/bike if i mouse over e.g. the bike project. but no matter which project i choose each time only one certain single other project is shown. no running no bike just lets name it nutrition. but i have no idea why. my single page is called single-projects.php . and also the adressbar is showing the correct adress like e.g. localhost:8888/testsite/projects/running in the case i’ve clicked running – but the content shows nutrition.
The query part on the single-projects.php page looks like that. For testing purpose i’ve only queried the title, description and services.
<?php $args = array( 'post_type' => 'projects', 'posts_per_page' => 1 ); $the_query = new WP_Query( $args ); ?> <? if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h3><?php the_title(); ?></h3> <p><?php the_field( 'pro_description' ); ?></p> <h4>Our services</h4> <?php if(get_field( 'pro_services' ) ): ?> <ul> <?php while( has_sub_field( 'pro_services' ) ): ?> <li><?php the_sub_field( 'pro_service_single' ); ?></li> <?php endwhile; ?> </ul> <?php endif; ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php else: ?> <p>Something is gone wrong...</p> <?php endif; ?>
I am out of ideas what is going wrong here. :/ any hints are appreciated. best regards ralf
- The topic ‘Always the same post of a custom post type is shown on a single page’ is closed to new replies.