• cordeliamars

    (@cordeliamars)


    I am having trouble with displaying Previous Post when on the first page of the blog (there won’t be a previous post then, obviously) Vice versa on the latest post with ‘Next Post’.

    Right now, nothing is displayed if there is no previous/next page. This looks ugly, I think. (See https://www.vikingprincess.net/24/fibroids)

    Here is the solution that I want: When there is no previous post, I want a non-hyperlink in the place where the link would normally go, simply stating: “No previous page available”

    I can’t seem to produce any php that achieves this!

    Also, it appears that if you are on the first page and ask for the previous page, WP returns the name of the page you are on, instead of an empty string or null. Is this right?

    If so, does that mean that if current_title = previous_page_title , then I am on the first page and can display the “No previous entry” string?

    I am not very good at php and this is really driving me crazy!

    Please can you help to suggest a solution? Some php code or whatever the solution should be?

    Hope I am making sense and that you can help!
    Here is the code I am using right now:

    <!--Populate the CommentNavigation formatted as a Table -->
    <div id="nav_styling_table">
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td rowspan="2" id="arrow_deco_left" height="6%">
    <a href="<?php echo get_permalink($prev_post->ID)?>">
    <img id="arrow_deco_left_img" src="/imgs/left.gif" alt='Previous Post'></img>
    </a></td>
    
    <td id="post_previous">Previous Post:</td>
    <td id="post_next">Next Post:</td> 
    
    <td rowspan="2" id="arrow_deco_right" height="6%">
    <a href="<?php echo get_permalink($next_post->ID)?>">
    <img id="arrow_deco_right_img" src="/imgs/right.gif" alt='Next Post'></img>
    </a></td></tr>
    
    <td id="previous_post"> <?php previous_post      ('% <strong></strong> ', ''); ?></td>
    <td id="next_post"> <?php $next_title; ?></td></tr>
    </table>
  • The topic ‘Previous_post() Question’ is closed to new replies.