Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Guido Grulke
Guido Grulke
20,948 Points

How to make custom field viewable at page edit screen?

Hi all,

I followed the build a wordpress theme videos from zac and started to build my own one. Now is the day, where I want to give the users the possibility to make some easy text changes on their own.

What I have: The Site will only contain static pages. Therefore I use a blank front-page.php file which shows the custom-fields I created. The Webpage looks like it should. So everything is working so far, but I want to edit the content of the custom fields from the Page menu in the admin dashboard. There are extra menu items for each custom post type I created. ( I know how to disable them but need them at the moment). I want to see the existing fields within the edit page screen.

I'm able to create new content for custom fields from the edit page, but I'm not able to see the existing custom fields. Any idea how to get there?

example: custom post type: homepage custom fields belonging to hompeage: headline, subline and textarea

in the admin dashboard I see "homepage" with klick on it I see the existing entries (3).

I want ot see (and edit) these existing homepage fields from the admin dashboard: page --> all pages --> edit homepage

Thank you very much for a hint, how to bring that up and work. Maybe my head is in the wrong direction...

4 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi!

I'm a little confused about what you're trying to do here.

Did you create the new custom fields using a plugin? And you assigned those to appear on with post_type = pages. Then they're not showing up?

OR

Did you create custom post types and have them displaying in the front-page.php. If this is the case, you will not be able to edit the custom post type content from the homepage since the code you are displaying on the site homepage is actually custom post type content and not static page content.

Does that address your problem.

ps - Always use the 'wordpress' tag when posting WP topics! I went ahead and added it for you :)

Guido Grulke
Guido Grulke
20,948 Points

Hi Zac,

thanks for your reply and the hint with the tag - will do so.

I followed your videos to "Develop a WordPress theme" and also installed the advanced custom fields plugin in and the custom post type ui plugin.

From the front end side (internet visitor) everything is working. I used the front-page.php with post_type = > 'homepage'. 'homepage' is a custom post type which contains 3 fields. I already have the "standard editor" not displaying at the pages-->all pages --> home edit screen. (used the remove_meta_box('inside','page','normal'); command within functions.php. This is because the content for that page will only be generated through the content of the custom post type fields within the group 'homepage'.

This 'Homepage' edit page now offers the option to create new custom field content for the 'homepage' group. But the existing custom fields content is not displayed there. It will only show up when I enter the extra page from the dashboard on the left side, which is named like each custom field group, in that case 'homepage'.

What I try is, that the content editor not has to use 2 different places to edit content for one page. I wonder if there is a better way to do this or if I have to generate an own metabox (by a plugin) and then customize the edit page screen.

I think, that I need a static page, like 'Homepage', to have a place where the custom fields can be displayed. If not, to edit all the content through the custom field menu would be fine - but I don' know hot should that work.

Maybe a kind of special problem, because it is a full static page, without blog content. I just want to make it as simple as it could be for the content editor on the custom side.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi,

I think it might be better to create unique custom post type and fields for what you need. You can also customize what fields show up when editing what types of content as well as the ability to hide standard fields like the content field.

Hope that helps?

Guido Grulke
Guido Grulke
20,948 Points

Thank you Zac, I will check this and work on it.