Post area not linking to posts
# March 8, 2013 at 6:47 am
I feel like this is just something I am not thinking of, like having a post.php file or something.
I have been working all night and pretty out of it, but made some leaps and bounds. I have been working on my portfolio site locally so that when I redo it later I will know what I am doing.
Right now this is it: http://jtpenezich.com/
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(); ?>
< ?php the_post_thumbnail(); ?>
< ?php endwhile; ?>
< ?php wp_reset_postdata(); // reset the query ?>
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?# March 8, 2013 at 12:17 pm
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
You’ll want to look at this: http://codex.wordpress.org/File:Template_Hierarchy.png# March 8, 2013 at 5:58 pm
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.
You must be logged in to reply to this topic.