Git Product home page Git Product logo

Comments (4)

drewrawitz avatar drewrawitz commented on August 24, 2024 1

Although I just realized I can still assign ACF field groups to the "Front Page" page.

screen shot 2017-11-08 at 10 48 14 am

So you're right, there's no need to create a special template. Thanks!

from theme.

drewrawitz avatar drewrawitz commented on August 24, 2024

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.

jedrzejchalubek avatar jedrzejchalubek commented on August 24, 2024

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.

drewrawitz avatar drewrawitz commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.