• Hello,
    I have a wordpress website built with pages, like a classic website. It looks like the following :
    – page named “home” (page_id=2) uses a template homepage.php and is set as homepage in WP prefs
    – page named “misc” (page_id=3) uses a template misc.php

    When I go to my web site, I get the content of page “home” with an url like “www.mysite.com/”. I can browse to the “misc” page and the url will be “www.mysiste.com/?page_id=3”. Note the fact that page_id is not set or displayed for the homepage as it is the cause of my problem.

    Let’s say I want to display posts in each page. I add some PHP code to each template, using posts_query to retrieve the posts I want (i.e. “home” will display all posts while “misc” will display only one category). All works well until I want to page the posts displayed : e.g. I have 10 posts and I want to display 4 per page.

    It works as expected on the “misc” page which is not set as homepage (I get urls like mysite.com?page_id=3&paged=2) but it doesn’t work on the “home” page. As the page_id in the url is not set (mysite.com/?paged=2 instead of mysite.com/?page_id=2&paged=2) : when displaying the previous posts I get the index.php page instead of my homepage.php template.

    Any idea of how to display paged posts on a templated page set as homepage ?

    Here is the code of my homepage.php template, if it can help to point out a problem :

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    /*
    Template Name: Homepage
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<div class="entry">
    				<div id="homepage_text">
    					<?php the_content(); ?>
    				</div>
    			</div>
    		</div>
    
    		<?php edit_post_link('Edit this page.', '<p>', '</p>'); ?>
    	 <?php endwhile; endif; ?>
    
    	<div id="blog">
    		<?php query_posts('showposts=4'.'&paged='.$paged);
    
    		global $more;
    		// set $more to 0 in order to only get the first part of the post
    		$more = 0; 
    
    		while (have_posts()) : the_post(); ?>
    			<div <?php post_class() ?>>
    				<small class="blog_date"><?php the_time('l j F Y') ?></small>
    				<h3 id="post-<?php the_ID(); ?>"><a>" rel="bookmark" title="Permalink to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    				<div class="entry">
    					<?php the_content('Read the full article &raquo;'); ?>
    				</div>
    				<p class="postmetadata">
    				<?php the_tags('Keywords&nbsp;: ', ', ', ''); ?> Published in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No comment ?', '1 comment ?', '% comments ?', 'comments-link', 'Commentaires are closed'); ?>
    				</p>
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older articles') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer articles &raquo;') ?></div>
    		</div>
    		<?php wp_reset_query(); ?>
    
    	</div>
    </div>
    
    <?php /* get_sidebar(); */ ?>
    <?php get_footer(); ?>

Viewing 7 replies - 31 through 37 (of 37 total)
  • OK OK OK, i solved it

    apparently CSS rules are obviously changed on pages, so just make sure you max-width and max-heigh are set to 100%

    you can view any weird css happenings going on with firebug, this was not a plugin issue, just something not expected since css checks were probably never done for this theme with all the modifications i have done, hope that helps people!

    Glad you worked it out.

    vtxyzzy, i have figured out from another post how to get to the ‘first post’ and ‘last post’ but what if i want to get to the first page of posts, i currently want to display 3, so instead of just older posts newer posts i want to display Oldest Posts and Newest Posts. Newest posts is easy b/c its always the first page of that post, i am thinking u have to reverse the posts order into descending or something, i am going to try something now.. but i thought i would put this is your queue, btw u got a google s/n for chat?

    vtx please help me masterrr

    I think you just need a second loop with ‘order=”ASC”‘.

    that query_posts($args); has no effect on the navigation, b/c that is referencing next and previous based on the current page, not all posts in the loop…

    OK tell me again just what it is you are trying to accomplish. Are you wanting to show ‘First Page’ and ‘Last Page’ in the navigation?

Viewing 7 replies - 31 through 37 (of 37 total)
  • The topic ‘How do I add posts on a templated page used as home ?’ is closed to new replies.