• Resolved Shaooxz

    (@shasoosh)


    I want that always the latest post of my blog will be hidden. I don’t want to use a plugin for it, I want it to still be public but i don’t want it to be show on the main page
    Thanks

Viewing 8 replies - 16 through 23 (of 23 total)
  • shasoosh, that is exactly what the code I posted will do: skip the first post on the first page and then show 4 posts per page without skipping any more.

    Unfortunately, you did not show enough code after the query_posts to be able to help find the problem. Maybe you should post the whole index.php in the pastebin and post the link here.

    Since I can’t see more code, this is a guess. You may be missing the while test after the query. Try using this:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $posts_per_page = 4;
    $offset = $posts_per_page * ($paged - 1) + 1;
    $args = array(
      'posts_per_page' => $posts_per_page,
      'paged' => $paged,
      'offset' => $offset,
    );
    query_posts($args);
    if (have_posts()) {  // You may need a colon here istead of a {
       while (have_posts()) {   // Same here
     ?>
    
    <div class="post-meta" id="post-<?php the_ID(); ?>">
    
    <div class="image">
        <h1><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
    </div>
    Thread Starter Shaooxz

    (@shasoosh)

    Nop, still getting an error.
    Here is my original index.php without any changes made from this thread
    https://dl.dropbox.com/u/17838/index.php

    Thanks guys ??

    OK – change this:

    <div id="post-entry">
    
    <?php $postcounter = 1; if (have_posts()) : ?>
    <?php while (have_posts()) : $postcounter = $postcounter + 1; the_post(); $do_not_duplicate = $post->ID; $the_post_ids = get_the_ID(); ?> 
    
    <div class="post-meta" id="post-<?php the_ID(); ?>">

    to this:

    <div id="post-entry">
    
    <?php $postcounter = 1;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $posts_per_page = 4;
    $offset = $posts_per_page * ($paged - 1) + 1;
    $args = array(
      'posts_per_page' => $posts_per_page,
      'paged' => $paged,
      'offset' => $offset,
    );
    query_posts($args);
    if (have_posts()) : ?>
    <?php while (have_posts()) : $postcounter = $postcounter + 1; the_post(); $do_not_duplicate = $post->ID; $the_post_ids = get_the_ID(); ?> 
    
    <div class="post-meta" id="post-<?php the_ID(); ?>">
    Thread Starter Shaooxz

    (@shasoosh)

    Works like a charm! Thanks all!!!! ??

    You are welcome!

    vtxyzzy

    I love you ??

    This worked great for me except that after page 6, the “older posts” button is no longer an option. If I go to ansonalex.com/page/7 the proper page displays however the navigation has disappeared. Here is my code (mine is a little different, I have 3 posts that I do not want displayed and I want to display 10 posts per page):

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 3;
    $posts_per_page = 10;
    $offset = $posts_per_page * ($paged - 3) + 3;
    $args = array(
      'posts_per_page' => $posts_per_page,
      'paged' => $paged,
      'offset' => $offset,
    );
    query_posts($args);
    
                if (have_posts ()) {
    
                    while (have_posts ()) {
    
                        (the_post());

    Update: There is also a “newer entries” link now on my index page, AnsonAlex.com, even though there aren’t any newer entries.

    If you click it, it takes you to the same place you go to when you click “older entries”.

    Other than those two above issues this fix works but if someone could shed some more light on the topic I would really appreciate it.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Hide the first post in my blog’ is closed to new replies.