Grow your CSS skills. Land your dream job.

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(); ?>

    # 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
    etc.

    You’ll want to look at this: http://codex.wordpress.org/File:Template_Hierarchy.png

    # March 8, 2013 at 1:28 pm

    I am only using my index file. 3 loops in it. Then the header/footer

    Edit: Just going to mark this solved. I just flew past making the single.php.. Forgot how magical WP was and was thinking way to deep.

    # March 8, 2013 at 3:28 pm

    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.

    # 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.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".