Part 3: index.php

This is where the fun part starts. Please open this file: index.txt. I wrote there some explanations and I divided it into sections so you know where to look. Also I want you to get an overall look on the code.

So let’s begin.
Section 1
As I said in the file, this is the link between index.php and header.php. It’s exactly like php includes, just a different code.

Section 2
My belief is that this code is for archives but I not really sure how it works because I never used it. If you want to use it, I suggest you so a google search about it and maybe you will figure it out. I left it there because I am actually afraid to delete codes from these files because it might mess up with everything. It’s no harm to leave it there.

Section 3
This is the code that actually get the posts on your homepage. This is where editing and stylizing everything begins. This is a must in your coding.

Section 4
The title. Nothing special about this. You can add background, colors, stylize the fonts add colors to the links, nothing special about this. It’s just the code that gets you the title of the blog.

Section 5
In this section, I chose to add a box to the content of the blog. So I can stylize it as I want, change the background, the font style and so on. This section include this code:

<?php the_content(__(‘Read More »’)); ?>

This is the code for getting the actual content of the blog post. And then you have this:

<?php if(function_exists(‘wp_paginate’)) {
wp_paginate();
} ?>

This is a code that will paginate your blog posts if you have the plugin installed (I suggest you install it because is amazing. Is called wp-paginate.
So basically this is what section five contains. The blog post and the paginate plugin.

Section 6
You seen on wordpress blog something like Posted on 5 July 2016, by Author in Life – 3 Comments. This is what’s in this section. The date when it was posted, the category where it was posted, the author of the post (this is your username) and the comments link.

Posted on
<?php the_time(‘ F jS, Y’) ?> – time
in
<?php the_category(‘, ‘) ?> – category
by
<?php the_author() ?> – author

The fun part is that you can move these around. Also, you can move them under the title (like many people have them), you can customize the text, you can do anything you like.

And for the comments:

<?php comments_popup_link(__(‘0 Comments’), __(‘1 Comment’), __(‘% Comments’), ‘commentslink’, __(‘sorry, Comments off for this post.’)); ?>

Same story for the comments link. See the messages: (‘0 Comments’), (‘1 Comments’), (‘%Comments’) and (‘sorry, Comments off for this post’). Well these you can change. Be careful, change only the text. Also you can add pictures as a background (using div and style.css), you can do whatever you want.

Section 7
Remember I opened a contentbox div? Well now I want to close it, because I want to have multiple bloxes, not everything on one box. So same old story, opened a div, now we’re closing it.

Section 8
I admit, I am not sure what this section does. It’s supposed to get the comments template, but I don’t see it’s purpose in this file. But I will leave it here because I don’t want to mess up anything.

Section 9
This is the section that will show those Newer Entries/Older Entries messages at the bottom of the blog (if you don’t have wp-paginate plugin installed).The same as for the comments link, you can modify ‘« Older Entries’ and ‘Newer Entries »’ and write whatever you want.

Section 10
Same as section 1, this will link index.php to footer.php. Also I noted in the .txt file that the link code to sidebar.php is in the footer.php file. Also we have the div that will close you content div opened in header.php

And that’s it. We’re done with index.php. It isn’t that hard. Now we move to single.php and after that to comments.php because they form the whole blog+comment area.