Closed. This question needs to be more focused. It is not currently accepting answers.admin管理员组文章数量:1122846
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 months ago.
Improve this questionHello WordPress community,
I'm working on a project where I need to create a custom post type using Advanced Custom Fields (ACF) and query it via WPGraphQL to integrate with a Headless Next.js build. Specifically, I want to achieve the following:
Single Instance Custom Post Type: I want to create a custom post type called "Homepage" that allows only one instance to exist. This single instance will represent the homepage of the website.
Limited Module Options: Within this "Homepage" custom post type, I'd like to restrict the editor to adding only a predefined set of modules (e.g., hero section, featured posts, gallery, etc.). The goal is to provide a structured and controlled editing experience.
Integration with WPGraphQL: Once the "Homepage" custom post type is set up with its limited module options, I intend to query this
data using WPGraphQL to retrieve and render it within a Headless
Next.js frontend.
I've already registered the custom post type using ACF, but I'm unsure how to enforce the single instance constraint and restrict the module options for the editor. Additionally, I'd appreciate any guidance on how to effectively query this custom post type data via WPGraphQL for seamless integration with Next.js.
Any advice, code examples, or resources related to achieving these goals would be greatly appreciated!
Thank you in advance for your assistance.
Best regards,
J
Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 months ago.
Improve this questionHello WordPress community,
I'm working on a project where I need to create a custom post type using Advanced Custom Fields (ACF) and query it via WPGraphQL to integrate with a Headless Next.js build. Specifically, I want to achieve the following:
Single Instance Custom Post Type: I want to create a custom post type called "Homepage" that allows only one instance to exist. This single instance will represent the homepage of the website.
Limited Module Options: Within this "Homepage" custom post type, I'd like to restrict the editor to adding only a predefined set of modules (e.g., hero section, featured posts, gallery, etc.). The goal is to provide a structured and controlled editing experience.
Integration with WPGraphQL: Once the "Homepage" custom post type is set up with its limited module options, I intend to query this
data using WPGraphQL to retrieve and render it within a Headless
Next.js frontend.
I've already registered the custom post type using ACF, but I'm unsure how to enforce the single instance constraint and restrict the module options for the editor. Additionally, I'd appreciate any guidance on how to effectively query this custom post type data via WPGraphQL for seamless integration with Next.js.
Any advice, code examples, or resources related to achieving these goals would be greatly appreciated!
Thank you in advance for your assistance.
Best regards,
J
Share Improve this question asked Apr 19, 2024 at 18:10 Jason6Jason6 11 Answer
Reset to default 1Custom Post types just don't really work like you want them to. "Post" types are fundamentally repeating types. My recommendation would be to use the pre-existing "Page" post type to create a home page. Here's some high-level steps
- Create a "Home" page under Pages
- In your site's "Reading" Settings select that page as your "Homepage"
- Create an ACF Field Group that only applies to that page.
If this doesn't work for you, try creating a cause "Options Page" with ACF (Requires Pro). That is a non-repeating type with only a single instance.
本文标签: Creating a Single Instance Custom Post Type with Limited Module Options using ACF and WPGraphQL
版权声明:本文标题:Creating a Single Instance Custom Post Type with Limited Module Options using ACF and WPGraphQL 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283301a1926925.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论