Viewing 6 replies - 16 through 21 (of 21 total)
  • kurtiskronk, what Dgold said is correct. In my theme, I don’t have a single.php because my single pages are styled the same way as my main page. Also, I don’t use pictures for my previous/next links.

    The code is in my index.php right after the start of the loop, which is the code that looks something like this:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?

    Of course, if I’d pasted the code in correctly, that would have helped, too. It really should be:
    <div>
    <?php if ($single) { ?>
    <?php previous_post_link('%link'); ?><a href="<?php echo bloginfo('url'); ?>/index.php"> | Main | </a><?php next_post_link('%link'); ?>
    <?php } ?>
    </div>

    This is the part that does the work:
    <?php previous_post_link('%link'); ?><a href="<?php echo bloginfo('url'); ?>/index.php"> | Main | </a><?php next_post_link('%link'); ?>

    Since the code is in my index.php page, I need the conditional statement so it only shows up when it’s a single post page. If you have a single.php and put it there, you would not need it. The <div> is wrapped around the code so that it can be styled. I have it centered.

    Thread Starter kurtiskronk

    (@kurtiskronk)

    figaro: The file you put up does exactly what I’m looking for with the previous/next links, but for some reason it messes with the placement of the title of the single post you’re in?

    I altered the code a bit to this:

    <div id=”content”>
    <div class=”navigation”>
    <table width=”100%” cellspacing=”10″ style=”border-width: 0px;”>
    <tr><td width=”50%”>
    <div style=”float: left;”><?php previous_post_link(‘« %link’) ?></div>
    </td><td width=”50%”>
    <div style=”float: right;”><?php next_post_link(‘%link »’) ?></div>
    </td></tr>
    </table>
    </div>

    only problem now is that it’s giving me a table border even though I tell it not to.

    Thread Starter kurtiskronk

    (@kurtiskronk)

    This is what it looks like now, if you want to see it, with the table border and all:

    https://kurtiskronk.com/2008/12/12/two-cubed/

    Humm…not sure where the table is coming from. I didn’t put it in the file and it’s not showing on my site. The only thing I added to the file is the following:

    <div id=”content”>
    <div class=”navigation”>
    <div class=”alignleft”>
    <?php previous_post_link(‘« %link’) ?>
    </div>
    <div class=”alignright”><?php next_post_link(‘%link »’) ?>
    </div>
    </div>

    Look in the file and make sure there is no table html in that code. If not, then it must be coming from the styling in your theme…I’m using the same theme at the link below and have no table borders…

    https://heraldleader.org/wordpress/?p=13

    Thread Starter kurtiskronk

    (@kurtiskronk)

    No no, I added the table, so that the next/previous would each be on one half of the same line, I don’t like it when they wrap one line on top of the other.

    And there is a problem that came from me putting your code before I modified it for some reason. Somehow, it messes up the placement of the post title, at least it does in Firefox, not sure about other browsers. For me, it would randomly indent it varying numbers of pixels

    Thread Starter kurtiskronk

    (@kurtiskronk)

    I went ahead and removed the table since I couldn’t get some parts of the border to go away and I got it looking good enough anyways with a couple quick alterations to the code, as seen below:

    <div class="navigation" style="padding-top: 15px; padding-bottom: 10px;">
    	<div style="float: left;"><?php previous_post_link('&laquo; %link') ?></div>
    	<div style="float: right;"><?php next_post_link('%link &raquo;') ?></div>
    </div>

    I ended up putting this at the top of the post and at the bottom as well, above the comments.

    Here’s the end result: https://kurtiskronk.com/2008/12/16/standing-in-wait/

    And for reference, for anyone else looking to do the same thing, here are the entire contents of my single_default.php for the Carrington theme:

    <?php
    
    // This file is part of the Carrington Theme for WordPress
    // https://carringtontheme.com
    //
    // Copyright (c) 2008 Crowd Favorite, Ltd. All rights reserved.
    // https://crowdfavorite.com
    //
    // Released under the GPL license
    // https://www.opensource.org/licenses/gpl-license.php
    //
    // **********************************************************************
    // This program is distributed in the hope that it will be useful, but
    // WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    // **********************************************************************
    
    if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
    if (CFCT_DEBUG) { cfct_banner(__FILE__); }
    
    get_header();
    
    ?>
    
    <div id="content">
    
    <div class="navigation" style="padding-top: 15px; padding-bottom: 10px;">
    	<div style="float: left;"><?php previous_post_link('&laquo; %link') ?></div>
    	<div style="float: right;"><?php next_post_link('%link &raquo;') ?></div>
    </div>
    
    <?php
    	cfct_content();
    ?>
    
    <div class="navigation" style="padding-top: 15px; padding-bottom: 10px;">
    	<div style="float: left;"><?php previous_post_link('&laquo; %link') ?></div>
    	<div style="float: right;"><?php next_post_link('%link &raquo;') ?></div>
    </div>
    
    	<div id="comments">
    <?php
    	comments_template()
    ?>
    	</div><!--#comments-->
    </div><!--#content-->
    
    <?php
    get_sidebar();
    
    get_footer();
    
    ?>

    Many thanks to figaro, jabecker, and dgold for help doing this. Ended up being more simple than I realized, but the fact that this theme’s code was so different from my other themes confused me thoroughly. ??

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Linking to Previous / Next Post?’ is closed to new replies.