CalebBarnes / nextwp

http://nextwp.org/
7 stars 0 forks source link

(docs): Misc Fixes #72

Open mosesintech opened 4 months ago

mosesintech commented 4 months ago

This PR will update the templates example for custom page templates. It will also update the NEXT_SITE_URL env variable documentation to include a note about the trailing slash.

Issue: When following the documented example for adding a custom page template, the following warning was given:

[@nextwp/core] ⚠️ Template "testingTemplate" not found for type "page" on uri 'testing'.
Did you forget to add it to the templates object in src/templates/index?

This PR will add "Template" to the end of the page keys.

vercel[bot] commented 4 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-wordpress-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 9:54pm
nextwp-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 9:54pm
mosesintech commented 4 months ago

I haven't tested it just yet for the other template types.

Do custom post types, custom post templates, and custom archive templates also expect "Template" to the keys?

mosesintech commented 4 months ago

I found that the trailing slash is necessary in the NEXT_SITE_URL env variable, so I add a commit here to add a note to the docs explaining that.

CalebBarnes commented 4 months ago

Issue: When following the documented example for adding a custom page template, the following warning was given:

[@nextwp/core] ⚠️ Template "testingTemplate" not found for type "page" on uri 'testing'.
Did you forget to add it to the templates object in src/templates/index?

How were you adding the templates? Usually this should only happen if your template included the word "template" in the name.

Did you create php files in your wp theme or did you create the templates through the NextWP Toolkit plugin UI?

image image

NextWP Toolkit has this handy feature for creating templates without the need for adding php files, since we are building headless we don't really need anything in the template php file.

With this example in the screenshot, my templates object would look something like

const templates = {
  page: {
    default: DefaultPageTemplate,
    contact: ContactPageTemplate,
  }
}

This would probably be useful info to add to a docs guide like "Adding custom page templates" or similar.

mosesintech commented 3 months ago

Good point, Caleb. I was working too fast and too tired and didn't realize I actually named it Testing Template. Totally my bad.