Is it possible to limit a CPT to just one? What I’d like to accomplish is creating a CPT called “Home”. It will manage any and all elements on the home page. I want to program it so when the user clicks on the “Manage Home Page” link they will go straight to the edit post screen. They will skip over the “All Post” screen. Does anyone think this is even possible?
Or maybe someone has an idea to accomplish this goal a completely different?
I would suggest creating a Theme Options page for this purpose.
https://wordpress.stackexchange.com/questions/tagged/theme-options
add_options_page() in Codex.
Or is there anything special in the post edit screen that you want to use that would be hard to get into the Theme Options page?
You want this because your client is confused, and setting a page to the homepage will not do.
But your solution is a can of worms waiting to explode in your face, so instead I have a much better solution!
Use the home.php template
In WordPress by default home.php is used as the homepage. If it is not found, front-page.php is used, and if that isn’t found it uses index.php
So create home.php, put your homepage code in there, and then add a settings page with WYSIWYG editors and image uploaders for the various pieces of content. You can even link directly to the settings page from the frontend if logged in to the site.
If your client is still confused, use screensteps to show them how. Chances are your client is only confused because they haven’t invested any time to read instructions or figure it out.
The added bonus of this is it doesn’t leave any confusing steps like clicking on the listings and finding a single post available, and an ‘add new home page’ button that does nothing but generate warnings and permission denied messages.
May be this plugin could help you:
Author’s site
WordPress plugin
Steve, my understanding is that you want:
The code below will tweak the WordPress Admin to do the above:
Note users can still add the post to custom post type using
wp_insert_post
I’ve actually done something very similar to this. I used a few different things in conjunction, and it all worked very well for my (easily confused) client.
Basically, I started with a page called “home”. Then, using Advanced Custom Fields, I created the various fields I wanted the client to be able to control – two WYSIWYG fields, several image fields, a few link fields, you get the idea. Then, when setting up the rules for that ACF type, I hid the main ‘content’ area on the edit page. I made sure to add clear and concise rules for each content area to avoid confusion, so they would know exactly what they could and couldn’t do in each field.
So, when the client clicks “edit page” in the WordPress menu, they’re presented with the Edit Post page for “Home”, with all the areas they control laid out neatly.
Then, I set up the home.php template to call the field output in the proper places. There’s several nice tutorials and code snippes on the ACF main site.
It made a VERY happy client, and took a lot of future frustrating maintenance off my plate.