Making scroll page in wordpress

0

Good afternoon! I'm creating a thema in wordpress with scroll page.

My pages are divided by slug, page-services, page-portifolio, and so on. but when I put it to the loop it does not list the contents of the page in the case of the page.php and yes of the single.php, when I delete the loop it list normal what I type.

follow my index.php

<?php get_header(); ?>
<section id="services">
<?php get_template_part('page','service'); ?>
</section>

<!-- Portfolio Grid Section -->
<section id="portfolio" class="bg-light-gray">
<?php get_template_part('page','portifolio'); ?>
</section>

<!-- About Section -->
<section id="about">
 <?php get_template_part('page','quemsomos'); ?>
</section>

<!-- Team Section -->
<section id="team" class="bg-light-gray">
 <?php get_template_part('page','equipe'); ?>
</section>

<!-- Clients Aside -->
<aside class="clients">
 <?php get_template_part('page','clientes'); ?>
</aside>

<!-- Contact Section -->
<section id="contact">
<?php get_template_part('page','contatos'); ?>
</section>

<?php get_footer(); ?>

follow the page-service.php

<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
  <h2 class="section-heading">Services</h2>
  <h3 class="section-subheading text-muted">Lorem ipsum dolor sit amet consectetur.</h3>
</div>
</div>
<div class="row text-center">
<?php if (have_posts()): while (have_posts()) : the_post();?>
<p>
  <?php the_content();?>
</p>
<?php endwhile; else:?>
<?php endif;?>
</div>
</div>

Maybe he is not opening the content, because he is not calling a url but an ID ex: link

I'm using the Page scroll to id plugin

Could someone give me a help how to do a one-page scroll thema in wordpress? any good tutorials?

    
asked by anonymous 19.05.2015 / 19:45

1 answer

1

The get_template_part is just a way to reuse the code more easily. It is a way to apdronizar enter the topics how to use the include in PHP.

Your template does not work because it does not update the query, it only creates a new loop. As the original Loop probably only had one page, home, when you re-call the loop inside the sections it does not find anything else because it has reached the end.

Pro you want to do, it's best to use get_pages() to return an array of page objects. So:

index.php

<?php 
get_header();
$pages = get_pages();
foreach ($pages as $page){
echo '<section id="'.$page->title.'">';?>
<div class="container">
  <div class="row"> 
   <div class="col-lg-12 text-center">
     <h2 class="section-heading"><?php $page->title?></h2>
      <h3 class="section-subheading text-muted">Lorem ipsum dolor sit amet consectetur.</h3> 
   </div>
  </div> 
<div class="row text-center"> 
   <p>
  <?php $page->post_content; ?>

</p>

</div>
</div>
</section>
<?php
  }
 get_footer();
?>
    
21.05.2015 / 23:34