First / previous / next / latest in category links? (3 posts)

  1. dansclayton
    Posted 2 years ago #


    I'm currently trying to add a category to my site which will contain only webcomic drawings. I can get the theme to add a chunk of code under the posts in just that category, but the problem is I can't seem to find out how to do the following:

    1) Display a link to the first post in the current category,
    2) Display a link to the previous post in the current category,
    3) Display a link to the next post in the current category,
    4) Display a link to the latest post in the current category.

    Something like the following:

    <div class='comicbuttons'>
    <span class='cbtn first'>«FIRST</span>
    <span class='cbtn back'>< BACK</span>
    <span class='cbtn next'>NEXT ></span>
    <span class='cbtn latest'>LATEST »</span>

    [Moderator Note: Please post code & markup between backticks (not single quotes) or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    ... But obviously with the text linking to the first, previous, next and latest posts in the category.

    I've tried searching the support pages and have found a few seperate chunks of PHP which all seem to interfere with each other, and unfortunately I'm more experienced with HTML and CSS.

    I've also played around with ComicPress a bit, but didn't really get on with it as a theme or as a variant of wordpress, so just using a category which automatically places that block after it's content would be perfect for my needs really.

  2. haxxxton
    Posted 2 years ago #

    can you confirm that the area that allows you to 'enter a chunk of code' will allow you to input php.

    To test this you could try adding

    <?php echo 'test'; ?>

    if this displays the word 'test' only then there may be some code we can look at. however, i would be surprised if a theme will allow you to enter raw php code.

  3. dansclayton
    Posted 2 years ago #

    The code is to go within the loop (so allows PHP), specifically this part which is right underneath the php call for the_content();

    <?php if ( in_category ( 'comic' ) ) : ?>
    	<div class='comicbuttons'>
    		<span class='cbtn first'>FIRST</span>
    		<span class='cbtn back'>BACK</span>
    		<span class='cbtn next'>NEXT</span>
    		<span class='cbtn latest'>LATEST</span>
    <?php endif; ?>

    It can be seen in action here: http://www.flipsum.co.uk/410 (apologies for the mess, I'm renovating at the moment).

    I'm no expert on php - I've managed to put together most of my own theme with a combination of guesswork and searching the forums, but the category links have stumped me completely. Any help would be greatly appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic