0

I have created custom post type with name Projects. and also created single-projects.php. the code is here

<?php
                  $args = array(
                    'post_type' => 'projects',
                    'posts_per_page' => '1',
                    'post__not_in' => array( $post->ID )
                             );
                     // the query
                    $query = new WP_Query( $args );

                    // The Loop
                    if ( $query->have_posts() )  ?>

                 <?php while ( $query->have_posts() ) : $query->the_post() ; ?>

                                    <!-- start project content -->
                                    <div class="project-content">

                                        <h2>Your Project Description</h2>

                                      <?php the_content(); ?> 

                           </div>

                     <?php  endwhile;  ?>

Now i want to show the content for single page. But the content is not coming from related page. The content is coming from latest project content which i create. How can i solve the problem? thanks for help.

0

single-projects.php - should contain the following code:

<?php
get_header();
if (have_posts()) :
   while (have_posts()) :
      the_post();
         the_content();
   endwhile;
endif;
get_sidebar();
get_footer(); 
?>

To display tekschey record does not necessarily use $query = new WP_Query ($ args);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.