admin管理员组

文章数量:1122846

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 question

Hello 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 question

Hello 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 1
Add a comment  | 

1 Answer 1

Reset to default 1

Custom 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

  1. Create a "Home" page under Pages
  2. In your site's "Reading" Settings select that page as your "Homepage"
  3. 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