Comments (4)
Although I just realized I can still assign ACF field groups to the "Front Page" page.
So you're right, there's no need to create a special template. Thanks!
from theme.
Would I do something like this:
<?php
/* Template Name: Homepage */
namespace App\Theme;
use function App\Theme\template;
template('homepage');
and then create a file templates/homepage.tpl.php
and put all of my custom code in there?
from theme.
Would I do something like this:
<?php /* Template Name: Homepage */ namespace App\Theme; use function App\Theme\template; template('homepage');
and then create a file templates/homepage.tpl.php and put all of my custom code in there?
This is exactly what I would do.
I like to think about root files as some way of "controllers". They receive data and delegate to templates. In most simple websites they probably will only contain a call to the template()
function, but it really helps with separation of DB logic from layout layer and make it easy to re-use templates.
PS. It's maybe only an example, but for a homepage, I would switch WordPress reading settings to "static" and go with front-page.php
and index.php
files instead of creating a special template file.
from theme.
Got it, makes sense!
Yeah, the only reason I like to create a special template file for the homepage is because I usually have a lot of ACF field groups that are specific to the homepage design. So I normally create a page in the admin called "Home" and assign it to the homepage template so I can manage all of the custom fields from that page and feed it through the template.
I suppose I could store the homepage settings in an ACF Options page and just use front-page.php
but I like to keep it as a page to avoid any confusion.
Thanks for your help!
from theme.
Related Issues (20)
- Generating .pot files HOT 2
- Only '/public' should be accessible HOT 2
- wp_enqueue_style() $ver and $media parameters not working HOT 1
- Gravity Forms doesn't load required assets HOT 2
- Undefined offset: 1 in /app/public/wp-content/themes/mytheme/vendor/tonik/gin/src/Gin/Template/Template.php on line 146 HOT 2
- TailwindCSS HOT 3
- examples for including bootstraps css and js? HOT 2
- What are future plans for support of Tonik starter theme? HOT 4
- Hello theme
- SSL missing at labs.tonik.pl HOT 1
- Do we have a Elementor and Beaver Builder support? HOT 1
- found 82 vulnerabilities
- Import asset in javascript
- 在ajaxes.php文件请求数据时,使用new WP_Query,会显示错误500,谢谢。 HOT 1
- Import bootstrap.js HOT 2
- Default browser outline looks ugly
- running on m1 mac HOT 2
- Fatal error: Uncaught exception
- BrowserSync (or Webpack) refreshing the whole page instead of injecting changes
- First install HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from theme.