mmue
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [OnePress] Front page section on other pagesHallo @aprobert,
your question was a bit too inaccurate, so I didn’t know where to start “amateur-friendly”.
That’s why I hope you know how to create a child theme (https://codex.ww.wp.xz.cn/Child_Themes) and I answer @krlklm’s question:
From scratch, your child theme has 3 items:
the child theme DIRECTORY, I called it “twentyseventeen-child”, therein:
style.css
functions.phpWordpress uses different template php files (stubs) to display the site. All those template php stubs are in the theme directory \wp-content\themes\twentyseventeen\
There are:
front-page.php – to display the front page
page.php – for displaying ALL static pages
single.php – for displaying all single posts
and so onWhen you create a static page “Imprint” for your imprint, your “About us” page or something like that, you have several fields to fill in the wordpress editor.
If you set the page name “Imprint” and save that change then two other fields are automatically filled with “imprint” but can be changed:
– the permalink
– the “slug”, (in German wordpress backends its called “Titelform”), way down to the bottom of the pageThis slug field is maybe NOT shown, until you check-mark it in the “Ansicht anpassen” (edit view) dropdown at the top of the page.
And here’s the trick:
If you create a template php stub and give it the name “page-imprint.php”, your Static page with slug “imprint” is beeing rendered using this stub.In general: a static page with slug “Hallo123” is rendered by the stub file “page-Hallo123.php”, if that stub file exists. If it doesn’t exist, wordpress uses the “page.php”
So, if:
(1) If you take the page.php from the original twentyseventeen theme directory, copy it to your child theme directory and edit minor changes/adjustments in it, then ALL your pages will show those edits.
(2) If you take the page.php from the original twentyseventeen theme directory, copy it to your child theme directory and change the name to “page-imprint.php” then only your imprint will show your edits.
(3) If you take the “front-page.php” from the original twentyseventeen theme directory, copy it to your child theme directory and change the name from “front-page.php” to “page-section.php” then only a static wordpress page with the slug field set to “section” will be displayed in the frontpage style.
So I did the following:
First I took the file “front-page.php” from the original twentyseventeen theme directory, copied it to my child theme directory and changed the name from “front-page.php” to “page-section.php”. Then I created a static wordpress page with the name “Hallo!” and the the slug field set to “section”.
So this page “Hallo!” showed other pages as sections. Unfortunately you set those sections under design -> customizer -> theme options for your whole wordpress site.
So you have to disable the sectioning for your frontpage as I show at topic 2 of my post:
Once again I took the file “front-page.php” from the original twentyseventeen theme directory, copied it to my child theme directory but did NOT rename it.
And in this child theme version of the “front-page.php” I disabled the sectioning by setting the $num_sections to 0:
$num_sections = 0; // apply_filters( ‘twentyseventeen_front_page_sections’, 4 );Ahm, I’m not sure if it’s really much clearer now… 😉
CU Martin
Forum: Themes and Templates
In reply to: [OnePress] Front page section on other pagesHi there!
Edit: Sorry! I found this topic via Google search and didn’t realize it’s about the OnePress theme.
I had the same problem with the Twenty Seventeen theme and used the following workaround:1.)
Create a child theme and copy the parent’s “front-page.php” to a single page template, that is: “The template file used to render a static page (page post-type).”
with the name: page-{slug}.phpLet’s say: Create a static page with the slug “section”, WordPress will try to use single page template “page-section.php” to display that static page.
If you use the parent’s “front-page.php” for the single page template “page-section.php”, your static page with the slug “section” will be displayed through the front page template and thus have the front page layout.
So when you enable and set page sections for the front page within the theme customizer, then those sections will appear on your front page and on your static page with slug “section”.
2.)
Disable display of page sections for your front page:
a) Copy the parent theme’s “front-page.php” into your child theme directory.
b) Don’t change the name
c) Edit the file “front-page.php” as follows:find the line:
$num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 );set $num_sections to 0:
$num_sections = 0; // apply_filters( 'twentyseventeen_front_page_sections', 4 );So you can move the display of page sections from your front page to another static page. But you still have only one single configuration of sections to be shown within the theme customizer. To have more than one sectioning setup, you have to completely re-design the Twenty Seventeen theme.
Maybe I could help anyway,
Martin