WordPress.org

Support

Support » How-To and Troubleshooting » Post on page template

Post on page template

  • Hello all

    My site: http://www.gotodesigns.co.uk/ is a child of the twentyeleven theme. I have made the front page static in the reading menu, and made a page for the blog and selected this also.

    I made a custom page template for the front page called template-home.php.
    code here: http://pastebin.com/x2VpFWWm

    I want to display 2 of the latest blog posts in the left column. I have searched and come up with only one post on another site: http://www.corvidworks.com/articles/wordpress-content-on-other-pages
    This appears to be what i want.

    Is there a better/updated way to approach what im doing here? Or is the link to the corvidworks post still good practice and good to go ahead with.
    As this way doesn`t give me the linked header text and image from the original post.

    Regards

    Marcus

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi

    @esmi

    Forum Moderator

    That article describes how to display WordPress posts in a non-WordPress site. Assuming you are talking about your static home page, I’d suggest starting with multiple Loops. I’d also suggest that you rename your front page’s custom template to front-page.php. WP will automatically apply that template to a static front page.

    Thankyou esmi, i will give that a go. Don`t know how i overlooked the goal of that article!

    Thanks

    Marcus

    OK, i have renamed the custom template as you described.
    And have deleted the code taken from the article from the top of the page, but left the part that referenced the loop within the container i wanted to display the latest posts in.

    That now shows a h2 and a link which just loops back to the homepage.

    I would now just like to display two posts from my blog in that left hand container, preferably with the post thumbnail, is there a more specific way of doing this, or part of the codex that would simplify this for me, being a novice and all as i am 😉

    Thanks for the help

    marcus

    If you’re anxious to try it, I’m not great at this but I think this will work.

    <!--display posts-->
            <div class="news-left">	
    
    <?php query_posts( 'posts_per_page=2');
    
     while (have_posts()): the_post(); ?>
                    <h2><?php the_title(); ?></h2>
                   <?php the_post_thumbnail();?>
                      <?php the_excerpt(); ?>
    
                    <p><a href="<?php the_permalink(); ?>">Read more...</a></p>
                    <?php endwhile; ?>
    	</div>
    <!--end display posts-->

    Thanks deepbevel, that led me through to find some code that displays the title permalink, excerpt and read more. That all displays fine now, the only thing i cant get to display is the thumbnail. Here is my updated code: http://pastebin.com/9qCfc61Q

    I have the thumbnail in the post, i just cant get it to display.

    Also as i`m new to this, would someone please explain to me how the code shown in the previous posters post is a muliple loop, i cant seem to work out where one starts and the othwr ends.

    Thanks all

    Marcus

    It was because i wasn’t using the featured image functionality within the post, i was just inserting the image. Oh well, it`s all a learning curve..

    What i would like to be able to achieve though now is the same styling for the posts on the front-page as the ones on the blog page, that just means a simple underline under each post, any way to pull this from the blog posts? Or does this need to be done within a post??

    Also i`d like the read more to be right at the end of the text, as opposed to being underneath the paragraph where it is now.

    Any guidance warmly received.

    Marcus

    you’re talking about the output of the query, you can arrange it any order you like in the template. You can make it match the outpput of your blog page, or make it use the same style rules.
    Whatever is output will follow the style rules of your theme unless you specify otherwise in style.css. If you want to play around with styles you should get and learn to use (it’s easy) Mozilla Firebug, which is an add on for Firefox. It’s essential, it shows you and lets you copy the css code for whatever part of the site you click on, also lets you apply changes on the fly for a temporary preview. I’ll check back and see how you do later. Good luck!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Post on page template’ is closed to new replies.