WordPress Theme one page scroll

First of all, you should create a template file for your one page. Let’s call it template-one-page.php. The template name, commented inside the file, is the name that will appear in Page Attributes -> Template when you creating a page inside admin panel. After that create a page, ie Home, and assign as template your template. If you want your page to appear as front page (when you enter mydomain.com this page will be shown) go to Setting->Reading->Front page displays->A static page and set as front page your page.


<?php 
// File Security Check
defined('ABSPATH') OR exit;
/*

Template Name: One Page

*/
?>

Normally a one page has sections. So we want to decide what type of sections we want. It could be pages, child pages, posts, custom fields (like a repeater from ACF) etc.


$id = get_the_ID(); // The page id

$sections = get_posts(array('post_type' => 'page', 'post_parent' => $id)); // get all child pages

foreach ($sections as $key => $section):

ID); ?>> echo get_the_title($section->ID);
endforeach; Or with a Loop $id = get_the_ID(); // The page id $query = new WP_Query( array('post_type' => 'page', 'post_parent' => $id) ); // get all child pages if($query->have_posts()): while ( $query->have_posts() ) : $query->the_post();
>

endwhile; wp_reset_postdata(); endif;

One thought on “WordPress Theme one page scroll

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.