• The navigation works on category section, but it doesn’t work on the homepage. It stays the same.

    Here’s the code:

    <h2 class="page-title"></h2>
    
                <?php $theme->hook('content_before'); ?>
    
    <?php query_posts('cat=6&showposts=2&offset=1'); ?>
    
                <?php 
    
                    $is_post_wrap = 0;
    
                        if (have_posts()) : while (have_posts()) : the_post();
    
                        /**
    
                         * The default post formatting from the post.php template file will be used.
    
                         * If you want to customize the post formatting for your homepage:
    
                         * 
    
                         *   - Create a new file: post-homepage.php
    
                         *   - Copy/Paste the content of post.php to post-homepage.php
    
                         *   - Edit and customize the post-homepage.php file for your needs.
    
                         * 
    
                         * Learn more about the get_template_part() function: http://codex.wordpress.org/Function_Reference/get_template_part
    
                         */
    
                        $is_post_wrap++;
    
                            if($is_post_wrap == '1') {
    
                                ?><div class="post-wrap clearfix"><?php
    
                            }
    
                            get_template_part('post', 'homepage');
    
                            if($is_post_wrap == '2') {
    
                                $is_post_wrap = 0;
    
                                ?></div>
    
    <a
     href="http://selfexceed.com/category/blog/"><img
     style="border: 0px solid ; width: 327px; height: 132px;" alt="self improvement blog"
     src="http://selfexceed.com/wp-content/uploads/2012/12/Blog.png"></a><a
     href="http://selfexceed.com/category/videos/"><img
     style="border: 0px solid ; width: 327px; height: 132px;" alt="self improvement videos"
     src="http://selfexceed.com/wp-content/uploads/2012/12/Video.png"></a>
    
    <?php
    
                            }
    
                    endwhile;
    
                    else :
    
                        get_template_part('post', 'noresults');
    
                    endif; 
    
                        if($is_post_wrap == '1') {
    
                            ?></div><?php
    
                        } 
    
                    get_template_part('navigation');
    
                ?>
    
                <?php $theme->hook('content_after'); ?>
    
            </div><!-- #content -->
    
            <?php get_sidebars(); ?>
    
            <?php $theme->hook('main_after'); ?>
    
        </div><!-- #main -->

    I think it has to do with this code here <?php query_posts('cat=6&showposts=2&offset=1'); ?>

    I implemented this code in order to exclude a category and ever since then, goign to page 2, 3, and etc all stays the same.

    my website is http://selfexceed.com.

    Appreciate any help that I can get!

    http://wordpress.org/extend/plugins/wp-pagenavi/

Viewing 11 replies - 1 through 11 (of 11 total)
  • the ‘offset’ parameter in a query does not work with pagination;

    try to find a different way to exclude the first post.

    implemented this code in order to exclude a category

    review:
    http://codex.wordpress.org/Function_Reference/query_posts#Preserving_Existing_Query_Parameters

    what is the reason for the ‘offset’?

    Thread Starter dend359

    (@dend359)

    I implemented the offset so that it doesn’t show the latest post.

    No idea what I should replace offset with, but since you said it’s the perpetrator, then that must be the problem.

    Thread Starter dend359

    (@dend359)

    Bumping to see if anyone can help me, sorry!

    try and change this line:

    <?php query_posts('cat=6&showposts=2&offset=1'); ?>

    to:

    <?php $latest = get_posts('cat=6&posts_per_page=1');
    query_posts( array( 'cat' => 6, 'posts_per_page' => 2, 'paged' => get_query_var('paged'), 'post__not_in' => array( $latest[0]->ID ) ) ); ?>

    (untested)

    might make problems with pagination if the dashboard – settings – reading – blog pages show at most [ ] posts is not set to 2 as well

    Thread Starter dend359

    (@dend359)

    Thank you for your help!

    Unfortunately this still doesn’t work as the navigation page still displays the same thing on each page.

    try and replace:
    get_query_var('paged')
    with:
    get_query_var('page')

    Thread Starter dend359

    (@dend359)

    I tried replacing that but it’s still displaying the same thing.

    what is the full code of the template?
    (please use the pastebin – see http://codex.wordpress.org/Forum_Welcome#Posting_Code )

    Thread Starter dend359

    (@dend359)

    your first loop (with just one post) is messing with the ‘paged’ parameter; at least try to add wp_reset_query(); after teh first loop.

    generally, you could use only one single loop to show all posts and the first post in a different format; try the forum search if you can find some suggestions.

    please post here again if the simple fix does not work.

    I want to thank you “alchymyth” for your help.

    Im not a webdesigner and do not understand a bit about code. I just want to adapt a theme to my needs…. Thata why I looked for help in this forum.
    I didnt get the answer I nedded in my topic (which bytheway was closed by you “alchymyth”), but I got the solution for my problem in this topic.
    It worrked perfectly as I wanted just by adding the code you suggested to “dend359″… and I visited your blogs and became your fan.

    Thank you very much!!!!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Works in category but not on index’ is closed to new replies.