Ready to get started?Download WordPress


Works in category but not on index (12 posts)

  1. dend359
    Posted 2 years ago #

    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'); ?>
                    $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
                            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;
     style="border: 0px solid ; width: 327px; height: 132px;" alt="self improvement blog"
     style="border: 0px solid ; width: 327px; height: 132px;" alt="self improvement videos"
                    else :
                        get_template_part('post', 'noresults');
                        if($is_post_wrap == '1') {
                <?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!


  2. 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


    what is the reason for the 'offset'?

  3. dend359
    Posted 2 years ago #

    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.

  4. dend359
    Posted 2 years ago #

    Bumping to see if anyone can help me, sorry!

  5. try and change this line:

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


    <?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 ) ) ); ?>


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

  6. dend359
    Posted 2 years ago #

    Thank you for your help!

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

  7. try and replace:

  8. dend359
    Posted 2 years ago #

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

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

  10. dend359
    Posted 2 years ago #

  11. 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.

  12. joia
    Posted 1 year ago #

    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!!!!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.