Hide the first post in my blog
-
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
-
Try something like:
<?php $c = 0; if (have_posts()) : while (have_posts()) : the_post(); $c++; if( $c ==1 ) continue;?>
in your theme’s index,.php template file.
Thanks!
Works great for me. I’m betting you just added it to the index.php instead of replacing
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
with esmis code.I had another problem in the code but now it works but i got another problem. It’s hiding the first post in every page in my blog, i want it to hide just the first most updated post.
$paged = get_query_var('paged') ? get_query_var('paged') : 1 query_posts('offset=1&paged=$paged');
before this line
if (have_posts()) : while (have_posts()) : the_post();
Parse error: syntax error, unexpected T_STRING ?
<?php $c = 0; $paged = query_get_var('paged') ? query_get_var('paged') : 1 query_posts('offset=1&paged=$paged'); if (have_posts()) : while (have_posts()) : the_post(); $c++; if( $c ==1 ) continue;?>
<?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; query_posts('offset=1&paged=' . $paged); if (have_posts()) : while (have_posts()) : the_post(); ?>
Try this;
^
That shows me posts 2,3,4,5 in the first page but in page number 2 i also see posts number 2,3,4,5 π instead of 6,7,8,9global $query_string; query_posts($query_string . 'offset=1&posts_per_page=5&paged=' . $paged);
instead of
query_posts('offset=1&paged=' . $paged);
OR
<?php $c = 0; $paged = get_query_var('paged'); if (have_posts()) : while (have_posts()) : the_post(); $c++; if( $c ==1 && $paged <=1) continue;?>
I’ve configured word press to show me 5 posts at the main page (because i’m hiding the first) and after changing the code to your last offer i do get only posts 2,3,4,5 in the main page but in page number 2 i see 6,7,8,9,10 where i want to continue to see just 4 posts. Any idea?
Give this a try:
$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);
Parse error: syntax error, unexpected T_ENDWHILE
I copied that straight out of a working test file, so the error is not in the code I posted. Perhaps it is not in the correct place in your code. Post some of your with a few lines before and a few lines after the added code.
shasoosh, this works for me. I suspect, as vtxyzzy said, that you aren’t putting it in the right place. Out of curiosity, why do you want to hide the first post on each page?
few lines from my index.php:
<?php if ((!function_exists("check_theme_footer") || !function_exists("check_theme_header"))) { ?><?php { /* nothing */ } ?><?php } else { ?> <?php get_header(); ?> <?php include (TEMPLATEPATH . '/sidebar-left.php'); ?> <div id="content"> <div id="content-inner"> <?php $featured_slider_activate = get_option('rk_ecobox_featured_slider_activate'); if(($featured_slider_activate == '') || ($featured_slider_activate == 'No')) { ?> <?php { /* nothing */ } ?> <?php } else { ?> <?php if(is_home()) { ?> <?php include (TEMPLATEPATH . '/featured.php'); ?> <?php } ?> <?php } ?> <div id="post-entry"> <?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); ?> <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>
I don’t want to hide the first post on each page…. i’ll try to explain my self better. In my homepage and on every main page i got a summary of my 4 latest posts. Above that i got a slideshow of posts of my choosing. When i post something new i’m putting it in the slideshow and doesn’t want it to be shown again in the summary. (the slide show is on every main page) so what i want to accomplish is:
First post will be hidden from the summary but will still be public,
main page: 2,3,4,5
2 page: 6,7,8,9
3 page: 10,11,12,13
- The topic ‘Hide the first post in my blog’ is closed to new replies.