• Resolved sebramsland

    (@sebramsland)


    Hey guys!

    I’ve been editing my own theme for quite a while now, and thing are starting to get in place.

    However, I have a problem with correct paging.

    I want my website to show the very last (and single) blog post on the startpage. And by clicking the arrows on the right side, you browse back and forth through previous blog posts – still only showing one post at a time.

    And it does works. But by browsing back and forth through the previous blog posts, the URL only shows “/page/2/” (and so on) – and not the permalink to the blog post. (Which I have activated).

    As you probably understand, this can be an issue when someone wants to for example bookmark a specific blog post. Because when I add furthermore posts, the content of the bookmarked URL, lets say, “/page/10/” will change to a completely different blog post.

    So what am I doing wrong here?

    My loop looks like this:

    <?php get_header(); ?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
            <?php if (in_category('121')) continue; ?>
    
    			<?php include('fullscreen.php'); ?>
    
    		<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2>Ble ikke funnet</h2>
    		<p>Beklager, men du ser etter noe som ikke er her.</p>
    
    	<?php endif; ?>
    
    </div>
    
    <?php get_footer(); ?>

    The content of fullscreen.php:

    <div class="post clear" id="post-<?php the_ID(); ?>">
    <!--Loading display while images load-->
    
    <div id="loading">&nbsp;</div>
    
    <!--Slides-->
    <div id="supersize">
    
    	<?php the_content(); ?>
    
    </div>
    
    <!--Content area that hovers on top-->
        <div id="content">
            <div id="contentframe">
            <div id="date">
                <h1><?php the_time('d/m') ?></h1>
                <h2><?php the_time('Y') ?></h2>
            </div>
            <div id="text">
                <h1><?php the_title(); ?></h1>
                <h2><?php echo get_post_meta($post->ID, 'description', true); ?></h2>
            </div>
            <!--Navigation-->
            <div id="navigate">
                <div class="previous"><?php next_posts_link('&laquo; Next page') ?></div>
                <div class="next"><?php previous_posts_link('Previous page &raquo;') ?></div>
            </div>
    	</div>
    </div>

    Please help me out guys. I’m sure it’s just a small fixture.

    Example can be seen here:
    https://www.sebastianramsland.com

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m not sure how simple the fix is actually. WP needs that paging structure to calculate which posts to show on a page. You will probably have to use javascript to rewrite the url that gets shown– pretty sure you can do that. You might be able to do with .htaccess but I’m not that good with .htaccess. You could also do this by writing your own DB query to get your posts, rather than using default WP functions. Maybe clever use of query_posts() could pull it off, but I’m not sure. It would look something like this:

    1) Grab your first and second post in reverse chronological order.
    2) Display the first post.
    3) Use the second for your next link.
    4) Click next.
    5) Parse the URL for the post name.
    6) Use the post name to grab the post and the one above and below.
    7) Show the middle post.
    8) Use above and below as links.
    9) And so on…

    Neat. ??

    Now watch someone tell me you can flip a switch in the backend and get the same effect.

    Thread Starter sebramsland

    (@sebramsland)

    I finally worked it out by looking at some other themes with almost same “setup”.

    The fix:

    <div id="navigate">
                <div class="next"><?php if(is_home()) $wp_query->is_single = 1; next_post_link('%link','&rsaquo;'); if(is_home()) $wp_query->is_single = 0; ?></div>
                <div class="previous"><?php if(is_home()) $wp_query->is_single = 1; previous_post_link('%link','&rsaquo;'); if(is_home()) $wp_query->is_single = 0; ?></div>
    </div>

    Thanks for the help anyways! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help needed with correct paging’ is closed to new replies.