Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I hard coded the html from resources.php from a site into page I created the wordpress admin, which used the default page template. Then I entered the following code into the page.php template. The result is http://strategichospitalitysearch.com/blog/resources.

 <!-- Start Page Content -->         
 <h1 class="blog-title"><?php the_title(); ?></h1>

     <?php 
     $page_id = 98; 
     $page_data = get_page( $page_id ); 
     $content = apply_filters('the_content', $page_data->post_content); 
     $title = $page_data->post_title; // Get title
     echo $content; // Output Content
     ?>   
 <!-- End Page Content -->
 </div> 

 <!--End Main Content -->

</div>
<!-- End Container -->

My Problem is that it may not work for other pages in the future and the subpages for resources. What is the best approach to this?

share|improve this question
add comment

1 Answer

if i understand right the problem is that you assign a static $page_id = 98; so no matter what page you go to it will only display that page's content.

what you need is to use the WordPress loop so change your code to this

<!-- Start Page Content -->         
 <h1 class="blog-title"><?php the_title(); ?></h1>
<?php 
     if (have_posts()) : while (have_posts()) :  the_post();
          the_content();
       endwhile;
     endif;    
 ?>   
 <!-- End Page Content -->
 </div> 

 <!--End Main Content -->

</div>
<!-- End Container -->

this why you get the same results but it will work on all pages.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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