• 10sexyapples

    (@10sexyapples)


    Not the sharpest marble in the toolbox when it comes to forums, so, I think first time ’round I posted this question in the wrong place, so, here it is again … hopefully in the right place this time-

    The problem:
    ?I need to display one specific post ( let’s call it an introductory post to the archive ), in full, on page 1 of a custom category archive (exhibitions) – and it needs to be called in by ID. I can’t use the sticky feature to have it always show there because I’m using sticky to call in featured posts on the homepage and don’t want to interfere with my coding on that, and having it in a separate category etc., would interfere with the CMS functionality of the site. I could just continually change the date on it to always make sure it was the most recent in the category, but, that would be horribly hackish.
    ?I need navigation on page one to the remainder of the category posts – the actual individual exhibitions.
    ?Page two and on, need to exclude the introductory post that is on page one and show 4 posts ( exhibitions ) per page.

    Here is what I thought was my almost working solution ( minus a way to call in the first post by ID and still have it page to page 2 – hadn’t gotten that far ):

    <?php
    $per_page = get_option('posts_per_page');
    $paged = (get_query_var('paged') && get_query_var('paged') > 1) ? get_query_var('paged') : 1;
    $cat = (get_query_var('cat')) ? get_query_var('cat') : 0;
    $offset = ($paged > 1) ? ($per_page * ($paged - 1) + 1) - $per_page : 0;
    $show = ($offset == 0) ? 'posts_per_page=1' : 'posts_per_page='.$per_page;
    query_posts("paged=$paged&cat=$cat&offset=$offset&$show");
    ?>
    
    <?php if ( $paged < 2 ) { ?>	
    
    <div id="nav"><?php posts_nav_link(' ', '<img src="' . get_bloginfo('template_url') . '/images/navigation/larrow.png" />', '<img src="' . get_bloginfo('template_url') . '/images/navigation/rarrow.png" />'); ?></div>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    //stuff//
    
    <?php endwhile; endif; ?>
    
    <?php } else { ?>
    
    <div id="nav"><?php posts_nav_link(' ', '<img src="' . get_bloginfo('template_url') . '/images/navigation/larrow.png" />', '<img src="' . get_bloginfo('template_url') . '/images/navigation/rarrow.png" />'); ?></div>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    /stuff/
    
    <?php endwhile; endif; ?>
    
    <?php } ?>

    Unfortunately, what I discovered is that this solution has a flaw, and one post, the last of six total, is being excluded from being shown. There should be one post ( introductory ) on page one, followed by four ( exhibition posts ) on page two, followed by the last ( for now until more are posted ) exhibition post on page 3.

    Instead, what I am getting is the introductory post on page one ( great ), four exhibition posts on page two ( great ) and no 6th post or option to navigate to page three. The last post is totally missing. And it is the last post that is missing, not the first, so, I’m baffled. Any wisdom anyone could give would be greatly appreciated of course.

    I’m all ears and thank you in advance to anyone who can help me solve this~

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter 10sexyapples

    (@10sexyapples)

    Man, I’ve been reading the forums for years and people always seem so helpful. Figures … the first time I actually need help myself, and it’s like a ghost town out there. Anybody? Pretty please??? I’m so totally baffled over this and have been going around and around trying to figure out why not one combination of solutions will work. Should it really be that difficult to have one post styled differently show up on the first page of an archive, then have four posts on all remaining archive pages? I guess when you get a page conditional, page less than two – else, together with different post query in each – and css styling unique to each it’s too explosive a combo? Common, I know there is a genius out there somewhere that knows exactly what I’m doing wrong and just can’t wait to help tackle this … sugar on top and everything ….

    Deepak Chennoria

    (@deepakchennoria)

    Hello 10sexyapples…
    you can add a custom field to that post …
    as you can say specific_post=1 from wp-admin than paste below code to extract the post…

    $a = get_category_id('archive');   
    
    query_posts('cat=$a');
     		if ( have_posts() ) : while ( have_posts() ) : the_post();
    		 $post_custom_field = get_post_meta($post->ID, "specific_post", true);
    if($post_custom_field==1)
    {
    echo $post->ID."--".the_title()."";
    	echo the_content();
    
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post query and pagination problem’ is closed to new replies.