• Resolved jrstudio

    (@jrstudio)


    Hi all,

    I’ll need your help.

    So, I made a so called static front page, just by modifying index.php, but then of course I wanted a page where I could list all posts, so I made that to. But now the problem is that I cant get “next_posts_link” and “previous_posts_link”.

    <div id="content">
        <?php
    		$args = array( 'numberposts' => 10 );
    		$myposts = get_posts($args);
        	foreach($myposts as $post) :
        	setup_postdata($post);
    	?>
         <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>             
    
            <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __('%s', 'mytheme'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    
            <div class="entry-meta">
                            <span class="meta-prep meta-prep-author"><?php _e('Written by ', 'mytheme'); ?></span>
                            <span class="author vcard"><a class="url fn n" href="<?php echo get_author_link( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( 'View all posts by %s', 'mytheme' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span>
                            <span class="meta-sep">. </span>
                            <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in ', 'mytheme' ); ?></span><?php echo get_the_category_list(', '); ?></span>
                            <span class="meta-prep meta-prep-entry-date"><?php _e('', 'mytheme'); ?></span>
                            <span class="entry-date"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time( get_option( 'date_format' ) ); ?></abbr></span>
                            <?php edit_post_link( __( 'Edit', 'mytheme' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t" ) ?>
            </div><!-- .entry-meta -->
    
    		<div class="entry-content">
    		<?php global $more; $more = 0; the_content( __( '', 'mytheme' )  ); ?>
            <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'mytheme' ) . '&after=</div>') ?>
    		</div>
    
            <div class="entry-utility">
                  <a class="comments-link" href="<?php comments_link(); ?>" title="Comment on <?php printf( __('%s', 'mytheme'), the_title_attribute('echo=0') ); ?>"> </a>
                   <a class="readmore-link" href="<?php the_permalink(); ?>" title="Continue reading..." > </a>
            </div><!-- #entry-utility -->   
    
          </div><!-- #post-<?php the_ID(); ?> -->
             <?php endforeach; wp_reset_postdata(); ?>
    				<div id="nav-below" class="navigation">
                        <?php next_posts_link(__( '<span class="meta-nav" title="Older posts"><div class="nav-older"></div></span>', 'mytheme' )) ?>
                       <?php previous_posts_link(__( '<span class="meta-nav" title="Newer posts"> <div class="nav-newer"></div></span>', 'mytheme' )) ?>
                   </div><!-- #nav-below -->
    
    	</div>

    This is main code inside #content. I managed to make everything look as I planed but now the only problem is that there is no next or previous posts but it is stated there in code. I know I’m doing something wrong here but I’m not so big expert in PHP.

    So if there is someone willing to help me, just to get that next and previous posts link I would be very very grateful man.

    Cheers.

    EDIT
    Suddenly after posting this thread occured to me, should I use posts_per_page in $args array, but thats in query_posts command? hmmm. Would next and previous work then?

  • The topic ‘"Show all posts" template.php — problem’ is closed to new replies.