• Resolved yuriyWP

    (@yuriywp)


    Im just developing my new blog, and i have total of 16 dummy posts for tests and all.
    However my plug in that im using is “wp-PageNavi” and its showing more pages and all extra pages that its showing have 404 error.? First off there should not be any extra pages other then 2 pages of posts which is correct.
    -Also when im using WP’s stock way of doing this the “preview post & next post” it has same problem it has 2 extra pages and also they show error log when going to them???

    In my “setting -> Reading” tab its all default to 10. So thats correct?

    COULD IT BE MY CODE???????

    Here is my loop
    ‘<?php $wp_query = new WP_Query(array(‘post_type’=>post, ‘paged’ => $paged, ‘posts_per_page’=>10,’orderby’=>Date, ‘order’=>DESC)); ?>
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); wp_reset_query(); ?>’

    And here is html code

    ‘ <?php endwhile; ?>’ the ending of the loop.

    I have really ran out of solution to what could be wrong, can someone see my site and this error plz plz help…

    http://www.yuriyphotography.com/blog/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter yuriyWP

    (@yuriywp)

    This is my index.php page’s code if its gana help….

    <?php get_header(); ?>
    <?php the_post(); ?>
        <div id="info_div">
        	<div id="location_text"><p><a href="<?php bloginfo('home'); ?>">Home</a></p></div><!-- location_text -->
            <div id="search_box">
            	<form id="searchForm">
                    <fieldset>
                        <div class="input">
                            <input type="text" name="s" id="s" style="color: #000; font-weight:700;"value="Enter your search" />
                        </div>
                        <input type="submit" id="searchSubmit" value="" />
                    </fieldset>
                </form>
            </div><!-- search_box -->
            <div id="clear" class="clear"></div>
        </div><!-- info_div -->
    
    	<div id="main">
    
        <?php // 'post_type'=>post, 'paged' => $paged, 'posts_per_page'=>10,'orderby'=>Date, 'order'=>DESC ?>
    	<?php $wp_query = new WP_Query(array('post_type'=>post, 'paged' => $paged, 'posts_per_page'=>10,'orderby'=>Date, 'order'=>DESC)); ?>
    		<?php while ($wp_query->have_posts()) : $wp_query->the_post(); wp_reset_query(); ?>
    
        	<div id="post_wrapper">
            	<div id="post_title"><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div><!-- post_title -->
                <div id="posted_info">
                	<span><img src="<?php bloginfo('template_url'); ?>/library/images/post_line_devider.png" /></span>
                    	<table width="720" border="0" cellspacing="5" cellpadding="0">
                          <tr>
                            <td width="32" scope="col"><img src="<?php bloginfo('template_url'); ?>/library/images/post_calendar.png" /></td>
                            <td width="280" align="left"  scope="col"><strong><?php the_time('F jS, Y'); ?></strong></td>
                            <td width="200" scope="col">&nbsp;</td>
                            <td width="32" scope="col"><img src="<?php bloginfo('template_url'); ?>/library/images/post_comments_BG.png"  /></td>
                            <td width="146" align="left" scope="col"><strong><?php comments_number(); ?></strong></td><!--<php comments_popup_link (); ?> -->
                          </tr>
                        </table>
                    <span><img src="<?php bloginfo('template_url'); ?>/library/images/post_line_devider.png" /></span>
            </div><!-- posted_info -->
                <div id="post_descriptive_image">
                	<!--<a href="<?php //the_permalink(); ?>"><?php //the_post_thumbnail('GeneralFuturedImage');?></a>-->
                    <?php
    				// Must be inside a loop.
    
    				if ( has_post_thumbnail() ) {
    					the_post_thumbnail('GeneralFuturedImage');
    				}
    				else {?>
    					<img src="<?php bloginfo('template_url');?>/library/images/post_thumbnail.png"  />
    				<?php }
    				?>
                </div><!-- post_descriptive_image -->
                <div id="post_about_text">
                	<?php the_excerpt(); ?>
                    <span class="read_more_link"><a href="<?php the_permalink(); ?>">Read More...</a></span>
                </div><!-- post_about_text -->
                <div id="post_tags">
                		<p>Posted in: <?php the_category(', '); ?></p><!-- Categories -->
                        <?php the_tags('<span class="tags-title">Tags:</span> ', ', ', ''); ?><!-- Tag's -->
                </div><!-- post_tags -->
                <div id="post_sharing_content">
    
                    <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=standard&show_faces=false&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe>
                    <?php edit_post_link( $link, $before, $after, $id ); ?><!-- Edit This button -->
    
                </div><!-- post_sharing_content -->
                <div id="post_devider_img"><center><img src="<?php bloginfo('template_url'); ?>/library/images/post_devider.png" /></center></div><!-- post_devider_img -->
            </div><!-- post_wrapper -->
    
           <?php endwhile; ?>
    
        </div><!-- main -->
        <?php get_sidebar(); // sidebar 1 ?>
    
        <div class="navigation">
    
        <?php wp_pagenavi(); ?>
        	  <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
                    <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
        </div>
    
        <div id="clear" class="clear"></div>
    <?php get_footer(); ?>

    show your function php file it will be there your problem
    3 and 4 page
    i can try to help you with the best of my knowladge

    Thread Starter yuriyWP

    (@yuriywp)

    ok sure this is my function.php page

    I have modified the loop a little in the index.php file to something like this
    AND its not showing me no error but it does gives me 2 extra pages.???
    Thanks for help.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('posts_per_page=10&paged=' . $paged);?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- all my code for the post -->
    
    <?php endwhile; ?>
    <?php else : ?>
    <h2>Not Found</h2>
    <?php endif; ?>
    <?php
    //this is my function.php file
    
    function my_post_queries( $query ) {
      // not an admin page and it is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_home()){
          $query->set('posts_per_page', 1);
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );
    
    // Thumbnail sizes
    add_image_size( 'bones-thumb-600', 600, 150, true );
    add_image_size( 'bones-thumb-300', 300, 100, true );
    
    // Sidebars & Widgetizes Areas
    function bones_register_sidebars() {
        register_sidebar(array(
        	'id' => 'sidebar1',
        	'name' => 'Sidebar 1',
        	'description' => 'The first (primary) sidebar.',
        	'before_widget' => '<div id="%1$s" class="widget %2$s">',
        	'after_widget' => '</div>',
        	'before_title' => '<h4 class="widgettitle">',
        	'after_title' => '</h4>',
        ));
    	if (function_exists('register_nav_menus')) {
    
    	register_nav_menus(
    		array(
    			'main_nav' => 'yuriyBlog_menu_1'
    		)
    	);
    }
    }
    
    // adding sidebars to WordPress
    add_action( 'widgets_init', 'bones_register_sidebars' );
    
    // Comment Layout
    function bones_comments($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment; ?>
    	<li <?php comment_class(); ?>>
    		<article id="comment-<?php comment_ID(); ?>">
    			<header class="comment-author vcard">
    				<?php echo get_avatar($comment,$size='32',$default='<path_to_url>' ); ?>
    				<?php printf(__('<cite class="fn">%s</cite>'), get_comment_author_link()) ?>
    				<time><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s'), get_comment_date(),  get_comment_time()) ?></a></time>
    				<?php edit_comment_link(__('(Edit)'),'  ','') ?>
    			</header>
    
    			<?php if ($comment->comment_approved == '0') : ?>
           			<div class="help">
              			<p><?php _e('Your comment is awaiting moderation.') ?></p>
              		</div>
    
    			<?php endif; ?>
    
    			<section class="comment_content clear">
    				<?php comment_text() ?>
    			</section>
    
    			<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    
    		</article>
        <!-- </li> is added by wordpress automatically -->
    <?php
    }
    
    // Add support for Featured Images
    if (function_exists('add_theme_support')) {
        add_theme_support('post-thumbnails');
    	add_image_size('GeneralFuturedImage', 700, 315, true);
    } 
    
    ?>
    Moderator keesiemeijer

    (@keesiemeijer)

    Is this your index.php? If so try it by querying from your theme’s functions.php
    http://codex.wordpress.org/Pagination#Removing_query_posts_from_the_main_loop

    function my_post_queries( $query ) {
      // not an admin page and is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_home()){
          $query->set('posts_per_page', 10);
          $query->set('post_type', 'post');
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );

    Moderator keesiemeijer

    (@keesiemeijer)

    Ok you allready have something similar in your functions.php. Try changing this:

    if(is_home()){
          $query->set('posts_per_page', 1);
    }

    to this:

    if(is_home()){
          $query->set('posts_per_page', 10);
    }

    And remove the query_posts in your index.php

    Thread Starter yuriyWP

    (@yuriywp)

    ok keesiemeijer i have tried this code in the functions

    if(is_home()){
          $query->set('posts_per_page', 10);
    }

    But still nothing so i changed it back to where it was however when i when’t to my loop thats in the index.php page i have changed the ‘posts_per_page=5 and it works like this

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('posts_per_page=5&paged=' . $paged);?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- loop code -->
    
    <?php endwhile; ?>
    		<?php else : ?>
            <h2>Not Found</h2>
            <?php endif; ?>

    But as soon as I change it to like 10 posts_per_page it brakes? any thoughts on this?

    Moderator keesiemeijer

    (@keesiemeijer)

    Query from your index.php or from your functions.php, not from both. The functions.php method is better and more predictable.

    Thread Starter yuriyWP

    (@yuriywp)

    Is there a way you could show me this in code example? on functions.php side?
    For some resone i cant get it to work.
    And how would my code look like in the index.php loop if i would change only to my functions.php file?

    thanks

    Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this in functions.php

    function my_post_queries( $query ) {
      // not an admin page and it is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_home()){
          // set the number of posts you want here
          $query->set('posts_per_page', 10);
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );

    And a normal loop in your index.php:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- loop code -->
    
    <?php endwhile; ?>
    <!-- pagination functions here -->
    <?php else : ?>
    <h2>Not Found</h2>
    <?php endif; ?>

    Maybe the <?php get_sidebar(); // sidebar 1 ?> before your pagination functions is messing things up. Try putting this just after it:

    <?php wp_reset_postdata(); ?>

    Thread Starter yuriyWP

    (@yuriywp)

    ok thank you keesiemeijer for all you help, I have solved it.

    For all of u that might have this issue here is my final code… 🙂

    This is how my loop look’s like in the index.php and all other pages like category.php archive.php basically the pages that have loop and pag-navi is required.

    index.php =

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') :1; query_posts('paged=' . $paged);?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- the loop code gove's here -->
    
    <?php endwhile; ?>
    <?php wp_pagenavi(); ?>
    <?php else : ?>
    <h2>No Posts Found</h2>
    <?php endif; ?>

    And this is the code that your functions.php file should have for this to work, and i have same thing.

    function my_post_queries( $query ) {
      // not an admin page and it is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_home()){
          // set the number of posts you want here
          $query->set('posts_per_page', 10);
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );

    Also notice that i have 10 post’s per page showing this number 10 should be the same as in your WordPress admin in here “setting -> Reading” and your “Blog pages show at most” should have same post_per_page number as the 1 in functions file, and you can change that number to what ever posts per page you want but change in both places…. Alright and thats all.

    Thread Starter yuriyWP

    (@yuriywp)

    UPDATE of the above code READ plz….

    for index.php this fallowing loop works grate

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') :1; query_posts('paged=' . $paged);?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- the loop code gove's here -->
    
    <?php endwhile; ?>
    <?php wp_pagenavi(); ?>
    <?php else : ?>
    <h2>No Posts Found</h2>
    <?php endif; ?>

    However for other pages like
    archive.php
    category.phg
    and so on use this looping style.

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- the loop code gove's here -->
    
    <?php endwhile; ?>
    <?php wp_pagenavi(); ?>
    <?php else : ?>
    <h2>No Posts Found</h2>
    <?php endif; ?>

    Thats the update

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘WP-PageNavi Error in last pages and extra pages?’ is closed to new replies.