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

Gui Schneider
Gui Schneider
4,567 Points

How to customise the supplied files to use elsewhere?

I am using the files in the download section on my own page, but in my page the custom post type I created is called "patient_notes". When I tired changing some code in the php provided I got confused about how to rename them because the video describes a custom post type named "art" and the "php" file is also named "art". So in the...

get_template_part( 'content', 'art' ); ?>

...line of code below the WP_Query command I didn't understand if the content is referring to the "art.php" file or to the "art" custom post type content.

How can I rewrite each of the 3 files provided to suit my "patient_notes" custom post type?

4 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi!

There are a couple of things going on here.

  1. In WP_Query you would change the custom post parameter to your custom post type patient_notes
  2. The art.php file is only a custom page template and you can name it anything you like as long as when you make the page you select that template.
  3. All single template custom post types are named single-customposttype.php and work automatically.

Now, I have some questions for you please:

  1. Did you watch the videos and take the quizzes for the course?
  2. Did you try to code out the files yourself as you went through the course?
  3. Or did you just download the code files and immediately start trying to customize them.

The reason I ask these questions is because this 3 points I gave above should have been covered fairly well in the videos and I'm trying to understand if you worked through them all and still didn't understand or just skipped them over and went straight to what you're trying to do.

Gui Schneider
Gui Schneider
4,567 Points

Hi Zac, thanks for your reply :)

I did watch the video more than once actually. I went through this course before and as I was presented with the opportunity to create a site professionally I thought of Custom Post Types to solve one of my needs and came back to it. Didn't complete the quiz this time around, only watched the relevant videos and downloaded the files to see if they would serve if I changed the relevant code the custom post type I was building.

As I watched the videos I went about creating my own custom post type, and gave appropriate names to both my custom post type and custom fields. The confusing part for me was when I tried to replace the code in the supplied template files.... In the video, the word "art" was used to name the custom post type (and mine is named "patient_notess") and also in the file "art.php" and in your Custom Fields Group - all with the same word "art" in the video, but not in my site as I created them and named differently according to what I am building.

So when I tried to update the WP_Query I couldn't understand in the line <?php get_template_part( 'content', ‘art’ ); ?> which "art" you were referring to. So I updated all my names to the single word "patients" and repeated them everywhere you had "art" in the templates files and still didn't work.. I am using another theme instead of the twentythirteen and even pointed that in the supplied template code, but no luck so far. I wish I could post screenshots here.

I remember you mentioned that this type of code is covered in more depth in the Create a Custom Wordpress Theme track.. I suppose I would have to watch that too. I just decided to reach out to try and clear this doubt.

I hope I am making sense LOL.

Cheers.

Gui Schneider
Gui Schneider
4,567 Points

Ok... the page.php that is also within the art.php file is different on my site from what is supplied, of course. I forgot to insert my query in a copy of my own page.php named "patients.php" (which is replacing the art.php file in my case). Is that right?

I am not sure where exactly to place the query...

:(

Gui Schneider
Gui Schneider
4,567 Points

Thanks for making me take the quiz. It made me see that I missed using my own page.php to set up my patients.php template.

I've managed to make it work!!

And using Dreamweaver also helped me find error messages in specific lines. The standard Mac OS text editor also messed up quotation symbols.

Overall, I'm getting there!

Thanks