Scrolling page on wordpress

Asked

Viewed 382 times

0

good afternoon! am creating a Thema in wordpress with scroll page.

my pages are divided by Slug, page-services, page-portifolio and etc.. only when I put it in the loop it does not list the content of the pages in the case of page.php and yes of single.php, when I delete the loop it lists normal what I type.

follows 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(); ?>

follows 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 it is not opening the content, because it is not calling a url but an ID ex: http://localhost/wordpress/#services

I’m using the plugin Page scroll to id

Could someone give me a help on how to make a Thema one-page scroll on wordpress? some good tutorial?

  • These sections are categories, tags, post-types...? And you want to list all posts in each section or limit the amount?

  • @Ricardobrgweb serious pages, every session of this is a page.

1 answer

1

The get_template_part it’s just a way ed to reuse the code more easily. It’s a way to apdronize enter the themes the way to use include in PHP.

Your template doesn’t work because it doesn’t update the query, it just creates a new loop. Since the original Loop probably only had one page, the home, when you call again the loop within the sections it does not find anything else because it has already reached the end.

For what you want to do, the best is 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();
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.