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

Custom Post Type Wordpress

Hi, in the Wordpress Theme Development and in the section of "Building Page Templates in WordPress" CONTACT PAGE and "Custom Post Type Templates in WordPress" PORTFOLIO , it's look like same right ? both are using Page Template, but why PORTFOLIO using Advanced Custom Fields and WP_Query but Contact Page is not ?

thank you

Garrett Sanderson
Garrett Sanderson
12,735 Points

All routes in WordPress must have a page associated with them. However on the PORTFOLIO page Zach is grabbing the data from the custom post type. To put data on a page from a custom post type you need to use WP_Query, Zach attaches fields to that post type using the Advanced Custom Fields. And the loops through that data with the arguments associated with the custom post type.

The base loop for a page will by default grab whatever you have in the normal page content editor and title fields.

Also page templates are used in order to create various different layouts that a web design may call for. The index.php and page.php can be used as a default layout, where as a template name page-contact.php could be used for a more specific contact page layout.

Does this help clarify?

1 Answer

so, in the Contact Page (using custom page template) only for grabbing the_title, the_content , etc (static)? if i want to add custom loop in the contact page, i must using WP_Query ?