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

Konrad Pilch
Konrad Pilch
2,435 Points

I'm using good practices for this theme?

I'm using good practices on this theme ? on how exactly it shoudl be done? Okay.. there are few things i should change like the sticky navbar, whcih i did, i'm just getting comfortable with git, but it's that a good practice? customep post type, articles and all that? naming etc..

2 Answers

which theme? :-) You haven't provided any links...

Konrad Pilch
Konrad Pilch
2,435 Points

Hmm, interesting if i forgot or something. Well it's here

Tim Knight
Tim Knight
28,888 Points

Konrad,

If I was going to offer you some feedback here, it would be:

  1. Work on making your indentation consistent. There are instances of tabs or spaces of various sizes all throughout the code base. Some files aren't even indented which make them difficult to work with.
  2. Create a .gitignore file and add things like your .DS_Store file to that list. You don't want files like that dirtying up your codebase.
  3. Be VERY VERY careful with the content your pushing to your git repository that's public. Files like your wp-config.php shouldn't be made public with your database passwords and other secure keys that you want to keep private. Use your gitignore file for these and get them out of your repository.
Konrad Pilch
Konrad Pilch
2,435 Points

The indentation is due to sublime text which messes everything, and i can't waste time to go and indent every code. My sublime indentation always switches to two spaces, while I use 3. And sometimes 4 so it just gets messy.

Oh, right xd I'm new to git as well xd I'll try to do it some how, I'm not sure how I suppose to delete that file. I'd do it in few weeks, I'm doing git basics and stuff, the frontend track.

Thank you. What do you think about the code?

Tim Knight
Tim Knight
28,888 Points

I'd suggest then that you setup Sublime Text to use the indentions that you're wanting to use. I'm not suggesting that you reindent code that you didn't write, just that you're consistent. I'd stick with 2 or 4 typically... whatever you decide. Then while a PHP document in Sublime Text go up to your Preferences menu then Settings - More, and select Syntax Specific - User and set:

{
  "tab_size": 4
}

Or whatever you decide. I don't mean to harp on it too much, but it's good practice. If you feel it gets messy for you, it's going to feel worse for someone elseβ€”either a contributor or future you.

As for the codebase itself:

  1. Looking at your sidebar files, I don't think you really need the conditional check there, you could just output the function. You could alternatively use a ! statement to check that the sidebar is empty and show some default text there instead to inform the theme user what they need to do to add content.
  2. On your single-article.php file you might want to support multiple categories on an article. From the looks of it, your code assumes and supports only one category. The other post types like video don't seem to have categories finished up as those links are static within the document.
  3. Double check you home.php. From the looks of it all of your categories will be output within the same empty link. This happens as well in archive-article.php
  4. I know you're in the middle of working on it, but make sure your index.php and page.php files work. Right now they're just going to output their filename. Both of those files serve as defaults for posts and pages if other more specific files aren't available, so be sure not to break that workflow.

So just a few points I'd checkout. Doing WP theme development from scratch takes some practice, but you've got a good start here. Just keep working through it and remember to keep your theme files flexible to WordPress's features.