Support » Fixing WordPress » query post and navigation don't work

  • Hello,

    I try to query posts from category. but i have no luck. I just want to display one post, i succeed doing this with the simple query_post() but then navigation don’t work.

    I have tried with this:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=9&posts_per_page=1'.get_option('posts_per_page').'&paged=' . $paged);
    ?>

    but it don’t work for me. i get a lot of posts, but from the correct category.

    I’ve seen a some questions like this, but i don’t know how to use the answers..

    Please help me!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    try this:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=9&posts_per_page=1&paged=' . $paged);
    ?>

    i tried the code, it works to show only one post from category 9, but the navigation don’t work. is it something that is missing in my code?

    <?php
    /**
     * Template: Category.php
     *
     * @package WPFramework
     * @subpackage Template
     */
    
    get_header();
    ?>
    
    			<!--BEGIN #primary-->
    			<div id="primary" class="hfeed" >
    
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=9&posts_per_page=1&paged=' . $paged);
    ?>
    
                <?php if ( have_posts() ) : ?>
    
                    <h1 class="page-title archive-title">Category Archives: <span id="category-title"><?php single_cat_title(); ?></span></h1>
    <?php while ( have_posts() ) : the_post();  ?>
    
    				<div id="post-<?php the_ID(); ?>" class="<?php semantic_entries(); ?>">
    					<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    					<!--BEGIN .entry-meta .entry-header-->
    					<div class="entry-meta entry-header">
    						<span class="author vcard">Written by <?php printf( '<a class="url fn" href="' . get_author_posts_url( $authordata->ID, $authordata->user_nicename ) . '" title="' . sprintf( 'View all posts by %s', $authordata->display_name ) . '">' . get_the_author() . '</a>' ) ?></span>
    						<span class="published">on <abbr class="published-time" title="<?php the_time( get_option('date_format') .' - '. get_option('time_format') ); ?>"><?php the_time( get_option('date_format') ); ?></abbr></span>
    						<span class="meta-sep">&mdash;</span>
    						<span class="comment-count"><a href="<?php comments_link(); ?>"><?php comments_number( 'Leave a Comment', '1 Comment', '% Comments' ); ?></a></span>
    						<?php edit_post_link( 'edit', '<span class="edit-post">[', ']</span>' ); ?>
    					<!--END .entry-meta .entry-header-->
                        </div>
    
    					<!--BEGIN .entry-summary .article-->
    					<div class="entry-summary article">
    						<?php the_excerpt(); ?>
    					<!--END .entry-summary .article-->
    					</div>
    
    					<!--BEGIN .entry-meta .entry-footer-->
                        <div class="entry-meta entry-footer">
                        	<?php if ( framework_get_terms( 'cats' ) ) { ?>
                            <span class="entry-categories">Also posted in <?php echo framework_get_terms( 'cats' ); ?></span>
    						<?php } ?>
    						<?php if ( framework_get_terms( 'tags' ) ) { ?>
                            <?php if ( framework_get_terms( 'tags' ) and framework_get_terms( 'cats' ) ) { ?>
                            <span class="meta-sep">|</span>
    						<?php } ?>
                            <span class="entry-tags">Tagged <?php echo framework_get_terms( 'tags' ); ?></span>
                            <?php } ?>
    					<!--END .entry-meta .entry-footer-->
                        </div>
    				<!--END .hentry-->
    				</div>
    
    					 </li>
              </ul>
    
    				<?php endwhile;  ?>
    				<?php include ( TEMPLATEPATH . '/navigation.php' ); ?>
    				<?php else : ?>
    
    				<!--BEGIN #post-0-->
    				<div id="post-0" class="<?php semantic_entries(); ?>">
    					<h2 class="entry-title">Not Found</h2>
    
    					<!--BEGIN .entry-content-->
    					<div class="entry-content">
    						<p>Sorry, but you are looking for something that isn't here.</p>
    						<?php get_search_form(); ?>
    					<!--END .entry-content-->
    					</div>
    				<!--END #post-0-->
    				</div>
    
    			<?php endif; ?>
    			<!--END #primary .hfeed-->
    			</div>
    
    <?php if (in_category(array(8, 18, 19, 20, 22, 9, 10, 11, 12))) { get_sidebar(); } else {} ?>
    
    <?php get_footer(); ?>

    it works when i change in reading settings to only show one post, but that messes up my other category posts.. disturbing!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘query post and navigation don't work’ is closed to new replies.