However I am changing things up for when I remake it. Currently my index.php contains a hook to a template page and a custom query loop to grab all my other pages I want displayed normally (one long site).
My template page has 2 loops in it. These loops allow me to make a post of an image that I want to add to my portfolio. This in turn will be sucked onto the main page (via get_template) and display a thumbnail of the image (via post_thumbnail). This way I no longer need to manually crop a thumbnail, add it to the page, add a link, and then it would only be linked to the image, not the site.
How I have it now in the template file:
< ?php $custom_query = new WP_Query('post_type=post&category_name=web&order=ASC');
while($custom_query->have_posts()) : $custom_query->the_post(); ?>
As described above, the get_template grabs what this will post, the thumbnails currently, that I post in the category. This works fine (finally). However when I add a link so when you click the thumbnail to bring you to the full post, it says page not found, by using:
Setting the permalinks back to default at least doesn’t break it, but also doesn’t display the post. I guess since there is no loop set up for them to display that. Now that I think about it, I don’t really need a template source at all. I can just put the loops back into the index.php… So what should I be doing.. That when someone clicks the thumbnail it will link to the full post?
How many templates do you have? Generally, packing everything into index.php is a bad idea. I’m not 100% sure if you’re overloading it too much or not, since I can’t see how your theme is fully structured, but it’s something to keep in mind.
You have so many other templates that you can use!
Posts use single.php
Pages use page.php
Categories us category.php
Just as a note, any of the “the_XXX” style functions are meant to be used inside of “the loop”. If you want the same functionality outside of the loop, you’ll need to use the get_the_XXX or get_XXX variety.
Thanks yeah, I wasn’t copying my direct code, they are all inside the loops though. I honestly just forgot that WP is a wizard and automatically detects a post as a post, and therefore uses the chain of templates down to index. I cleaned things up a bit by having a front-page.php as my static page that holds my 3 loops and a single.php to hold my posts.