• I would like for each entry in my blog to show, in small type on the line below the post, something like:
    Previous Post Title << | MAIN | >> Next Post Title

    I found a plugin https://www.scriptygoddess.com/archives/2004/07/24/nextprevious-posts-in-same-category/ that I thought would do it, but I cant figure out how to make it work.

    The instructions say it has two functions:
    previous_cat_post();
    next_cat_post();
    but if I put them in my index.php file they just print

    How do I invoke them to get the string?

    It also shows a sample usage to be
    previous_cat_post($beforeGroup=’Previous Posts within categories’, $afterGroup=”, $beforeEach=’- ‘, $afterEach=”, $showtitle=false, $textForEach=’Previous post in %’);
    but if I put that in index.php it prints as well

Viewing 15 replies - 1 through 15 (of 17 total)
  • You have to put them within PHP tags, like follows.
    <?php previous_cat_post(); ?>

    Thread Starter singleton

    (@singleton)

    Thank you alphaoide

    The instructions say Each function has the following parameters you can pass to it: $showtitle (true | false) true if you want to include the title of the post in the link (see below for how this looks if set to false). Default is true.

    So I tried <?php previous_cat_post($showtitle(false)); ?> but I got Fatal error: Call to undefined function: () in /home/www/bushsupporter.org/html/wordpress/wp-content/themes/don01/index.php on line 20

    It works without the $showtitle(false) but it generates stuff I dont want

    Looks like the goddess’ abilities at instruction are a bit off. Try this:

    <?php previous_cat_post('<p>Previous Posts within categories</p>', '', '<p> ', '</p>', true); ?>

    Note how I specify (in order) just the values I want to pass, and not the argument variables. But to set the $showtitle parameter, I need to provide values to those before it. See this for more:

    https://codex.www.ads-software.com/Template_Tags/How_to_Pass_Tag_Parameters#Tags_with_PHP_function-style_parameters

    Thread Starter singleton

    (@singleton)

    Maybe this is the wrong plugin for me Nothing I can do seems to stop the “Previous Post in xxxx” I can turn off or on the post title, but that is all I want, the post’s title and not the identifying words.

    I guess I can always modify her plugin but do you know of a plugin that would do what I want, and that is just show the title (and link) of the previous post and the title (with link) of the next post

    We don’t really know what you want.
    The plugin is for displaying Next and Previous in the same category.
    If you just want to display the Next and Previous regardless of category, i.e. following the chronological order then just use the previous_post and next_post template tags.

    Thread Starter singleton

    (@singleton)

    I may have to settle for those two tags

    What I wanted was the previous and next in that category, I just dont want the string “Previous Post in xxxxx” where xxx is the category.

    If x and y are categories, and my most recent posts were
    x post1
    y post2
    x post3
    y post4
    x post5

    If I am looking at post 3 the tags you reference would give me post2 and post4

    What I am looking for is post1 and post5, but I dont want the specific string Previous post in x post1, I just want post1

    OK, I got it. And here is my $0.02.
    Since the majority of blogs display the Prev-Next posts chronologically, I think it’s not bad to warn your visitors that clicking the Next-Prev links will take them back and forth ONLY in the same category. But it’s your blog…

    Thread Starter singleton

    (@singleton)

    You make a good point

    But <?php next_post(); ?> does not show anything.

    Do I need to do anything to activate it?

    <?php previous_post(‘« « %’, ”, ‘yes’); ?>
    | <?php next_post(‘% » » ‘, ”, ‘yes’); ?>

    Just shows the “|”

    Thread Starter singleton

    (@singleton)

    It did not help me (I must be dumber than even I thought)

    The first link was where I got the code I tried

    If you got it to work, can you give me the exact string out of your index.php file?

    Try droping this in your index.php (or single.php if

    <?php if (is_single() ) { ?>
    <div class="nav">
    <?php previous_post('&laquo; %', '') ?> | <a href="<?php bloginfo('url'); ?>">Home</a> | <?php next_post('% &raquo;', '') ?>
    </div><!-- nav -->
    <?php } ?>

    within the loop, just below
    <?php if (have_posts()) : while....

    Mine looks like this:

    <div class=”previous_posts”><?php previous_post(‘%’, ‘Previous: ‘, ‘yes’, ‘no’); ?>
    || <?php next_post(‘%’, ‘Next: ‘, ‘yes’, ‘no’); ?></div>

    Thread Starter singleton

    (@singleton)

    There must be something I need to do to make the previous_post() function return something.

    I tried the string that oriecat suggested, and just got ||

    I used the string IanD suggested and got absolutely nothing (in other words I put x before the string, and y after the string and got xy)

    Okay, I use two different plugins to get the effect in my website in the sidebar’s post meta data section.

    The first one uses the Eric Meyer Plugin but it was “broken” so here is a paste bin link to my fixed version of that plugin.

    The second one uses Scriptygoddess Next Previous Post Plugin.

    <p class="postmetadata">This article is from the categories of <?php the_category(' and '); ?>. Updated <?php last_modified('F jS, Y'); ?>. <?php mw_previous_post('%', '', 'The previous article is ', '. ', 'yes', 'yes') ?><?php mw_next_post('%', '', 'The next article is ', '.', 'yes', 'yes') ?>
    <?php previous_cat_post($beforeGroup='', $afterGroup=' &laquo;&laquo; ', $beforeEach=' &bull; ', $afterEach='', $showtitle=false, $textForEach=' <b>%</b>'); ?>
    <?php next_cat_post($beforeGroup=' &raquo;&raquo; ', $afterGroup='', $beforeEach='', $afterEach=' &bull; ', $showtitle=false, $textForEach=' <b>%</b>'); ?>

    By the way, I REALLY am not happy with my layout as it won’t say within the categories, so I’ll be changing it soon now that the WordPress template tag will stay within categories…so they say.

    Thread Starter singleton

    (@singleton)

    I tried what Lorelle gave me for scriptygoddess since that is what I tried at the start, and got a few function not founds, and a few names of the categories.

    I think moshu is right, I should stick to the existing tags, and just get the previous and next tag irregardless of category. But the question is why they are returning null strings.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Previous and Next post’ is closed to new replies.