WordPress.org

Ready to get started?Download WordPress

Forums

Display post from one category - Pagination (4 posts)

  1. Hanz17
    Member
    Posted 10 months ago #

    Hi,
    I wanted on page only the posts from one category. That is what I want, but I do not know how to do pagination. I tried the instructions and or plugin, but nothing works. I want on one page previewed 7 posts and then it was pagination. Thanks for the advice :)

    I attach the code without pagination. And code pagination in template

    <?php
    /*
    Template Name: Hry
    */
    
    get_header();
    	$gazpo_settings = get_option( 'gazpo_options');
    
    ?>
    
    <?php 
    
    query_posts('posts_per_page=7&paged=' . $paged);
    ?>
    <div id="wrap" class="wide-content">		<div class="entry">						
    
    <div class="posts-list">
    
    <?php 
    
    	if (have_posts()) :
    			while (have_posts()) : the_post();
    				?>
    					<div id="post-<?php the_ID(); ?>" <?php post_class($classes); ?>>
    						<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    						<div class="post-meta">
    
    							<span class="info">
    								<span class="date"><?php the_time('M. d') ?></span>
    								<span class="category"><?php the_category(', ' ); ?></span>
    								<span class="comments"><?php comments_popup_link( __('no comments', 'silverorchid'), __( '1 comment', 'silverorchid'), __('% comments', 'silverorchid')); ?></span>
    							</span>								
    
    						</div> <!-- /post-meta -->
    
    						<div class="entry">
    
    						<?php
    							if ( $gazpo_settings['gazpo_read_more'] != ''){
    								$readmore_text= $gazpo_settings['gazpo_read_more'];
    							} else {
    								$readmore_text= 'Read more &rarr;';
    							}
    							the_content($readmore_text);
    						?>
    						</div> <!-- entry -->
    
    					</div><!-- /post-->
    
    			<?php
    				endwhile;
    			endif;
    		wp_reset_query(); 
    
    		?>
    
    </div>
    
    </div> <!-- entry --> 
    
    	</div><!-- /content -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    <div id="pagination">
    			<?php echo gazpo_pagination(); ?>
    		</div>

    Link on page:
    http://zoomon.cz/hry/

  2. xmatter
    Member
    Posted 10 months ago #

    I have used a page template for this:

    <?php
    /* Template Name: Single Category */
    ?>
    
    <?php get_header(); ?>
    
    <?php get_sidebar(); ?>
    
    <div id="content">
    
    	<?php
    
    	query_posts('showposts=-1&cat=13&orderby=rand');
    
    	if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    			<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
    			<?php the_meta(); ?>
    
    			<!--<?php the_post_thumbnail(); ?>-->
    
    	<?php endwhile; endif; ?>	
    
    	<?php wp_reset_query(); ?>
    
    </div><!-- end content -->
    
    <?php get_footer(); ?>

    change the cat13 to whatever your cat to be displayed is. Then you must change the PAGE to this page template.

  3. Hanz17
    Member
    Posted 10 months ago #

    Ok thanks but I need pagination too. I haven´t idea, how :D. I want only 7 posts on page, next 7 posts will be on second page, etc.

  4. alchymyth
    The Sweeper & Moderator
    Posted 10 months ago #

    review:

    http://codex.wordpress.org/Pagination‎

    the pagination code would likely go just after the endwhile of the loop;

    for how to integrate that into your theme, please contact the theme's developer for support.

    this forum only supports themes from http://wordpress.org/themes/

Reply

You must log in to post.

About this Topic

Tags

No tags yet.