WordPress.org

Forums

Ambrosite Next/Previous Post Link Plus
Seeking beta testers (21 posts)

  1. ambrosite
    Member
    Plugin Author

    Posted 5 years ago #

    I am currently seeking beta testers for version 2.0 of my Next/Previous Post Link Plus plugin for WordPress. I have made significant changes in this version to add some new features that were requested by users of the plugin. Specifically:

    * Sort the next/previous links on custom fields.
    * Return multiple next/previous links (e.g. the next N links, in an HTML list).
    * Optionally display the category of the next/previous links.
    * Full WordPress 3.0 compatibility.
    * Rewrote the plugin using wp_parse_args to simplify the function calls.

    This is in addition to the options that were included in version 1.1 of the plugin:

    * Sort the next/previous post links on columns other than post_date (e.g. ID, post_title, menu_order).
    * Loop around to the first post if there is no next post (and vice versa).
    * Truncate the link titles to any length, and display the full titles in the tooltip.
    * Display post thumbnails alongside the links (WordPress 2.9 or higher).
    * Return false if no next/previous post is found, so themes may conditionally display alternate text.

    Here is the link to the version 2.0 download and documentation. I would appreciate feedback from all WordPress users, and especially those using custom post types and/or custom taxonomies. Please post bug reports and feature requests in this thread; I'll be checking in regularly over the next several weeks until the beta period has ended. Thanks!

  2. henryleo
    Member
    Posted 5 years ago #

    Hello
    I am currently testing this plugin with WP 3.0 and using Custom Post Types with a Custom Taxonomy and experiencing problems.

    The "in_same_cat" feature is not working - in fact if I set this to TRUE or 1 than the links never appear and the page fails to load completely. If I remove the term than it loads fine but of course paginates between all taxonomies ...

    Thank you for your work with this plugin! Works great for everything else!

  3. ambrosite
    Member
    Plugin Author

    Posted 5 years ago #

    henryleo,

    Thanks for your feedback. I will try to replicate that problem on my test server. In the meantime, I am curious to know whether you experience the same problem using the core next/previous functions instead?

    http://codex.wordpress.org/Template_Tags/next_post_link

    http://codex.wordpress.org/Template_Tags/previous_post_link

    Also, in regard to the page failing to load: have you set 'loop' equal to TRUE?

  4. henryleo
    Member
    Posted 5 years ago #

    @ambrosite:
    Thank you for your quick response. To answer your questions, no I am not experiencing the problems using the default next/prev post links using normal categories. But if I use those functions on the single.php template that handles my custom taxonomy then the default links fail to load as well only if "in_same_cat" is set to true.

    The page itself is always loading and I would say 99% of its content shows up, but not the links and the little loading bar in the bottom of Firefox never reaches the end and says "waiting for http://www.mysite.com" with mysite.com being my clients domain name of course ;)

    Also I have tried this with loop set to both TRUE and FALSE and in an array and a single line declaration.

    Someone else had the same problem as me and your plugin fixed it for him... so its most likely something I am doing wrong.

    http://wordpress.org/support/topic/navigation-between-custom-post-types?replies=9

    I will post back here any updates - thanks you for helping!

  5. henryleo
    Member
    Posted 5 years ago #

    Ok so I have made some progress in that the links will always load now ... I erased all my previous code and started fresh. However they are still linking to the incorrect projects.

    For example:
    If I am viewing the 4th Post in the taxonomy "Print" than the next and previous links should be to the 3rd and 5th posts... but they are still linking to the adjacent posts from the main parent taxonomy "Type" ...

    So here is some back story:
    My custom post type is called "Projects" with a custom taxonomy of "Type" - where the children of "Type" are "Print", "Digital", "Identity", etc...

    So Im viewing a single Project in the Type "Print" and would like the prev/next links to only paginate between project in the same Type. Can this be done?

    Thank you!

  6. henryleo
    Member
    Posted 5 years ago #

    One more thing,
    I tried using ex_cats on custom taxonomies and again the links fail to load. here is the code I was testing:

    <?php previous_post_link_plus( array(
    'loop' => true,
    'ex_cats' => '12 and 14',
    ) ); ?>

    and im just using the normal WP loop on a custom single template ... and in my main single.php file I am using a conditional statement to load a specific single template depending on the taxonomy. sorry for overloading this thread!

  7. ambrosite
    Member
    Plugin Author

    Posted 5 years ago #

    henryleo,

    Thanks again for the detailed feedback, it is very helpful. I have just released an updated version of the plugin that should solve all the problems with custom taxonomies that you reported in this thread:

    http://www.ambrosite.com/download/ambrosite-post-link-plus.2.0.zip

    I'll come back in a bit and explain what I fixed. Let me know how this works for you.

  8. ambrosite
    Member
    Plugin Author

    Posted 5 years ago #

    Let me give some details on how I got this working with custom taxonomies, since a similar fix will have to be made to the core next/previous_post_link functions.

    The function in question is get_adjacent_post from wp-includes/link-template.php. Starting around line 1016 (in the 3.0.1 release), the function assumes a taxonomy of 'category':

    $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";

    But with custom taxonomies you cannot assume the taxonomy is 'category', since it is possible to register any number of hierarchical taxonomies. What we need to do instead is get the list of taxonomies for the current post. The code posted by iwanttobelieve in that other thread was on the right track, however his solution requires manually creating the array of taxonomies. Instead, I am retrieving the taxonomies using the following code:

    $taxonomies = array_filter( get_post_taxonomies($post->ID), "is_taxonomy_hierarchical" );

    The purpose of the filter is to take out non-hierarchical taxonomies like post_tag, since these functions were not designed to navigate through tag archives (although they could be used that way, if the filter was removed). Then it is simply a matter of substituting the taxonomy list in place of 'category':

    $join .= " AND tt.taxonomy IN (\"" . implode('", "', $taxonomies) . "\") AND tt.term_id IN (" . implode(',', $cat_array) . ")";

    Now the function will find next/previous links in any of the taxonomies (including customs) for the current post. I have rolled all of these fixes into my plugin, and it is working perfectly on my test server. Once the plugin is finalized and released to the repository, I will see about reporting this issue in Trac (assuming no one else gets to it before then).

  9. AliMH
    Member
    Posted 5 years ago #

    hey mate, i need to list all child posts to parent post like this

      more staffs

    • tom hanks
    • jenifer lopez
    • ....

    and all have link to their child posts.
    does this plugins able to do this for me?

  10. ambrosite
    Member
    Plugin Author

    Posted 5 years ago #

    AliMH,

    You are talking about Pages, not posts, right? Posts do not have parents and children (apart from attachments), only pages do.

    The next/previous_post_link functions are only designed to work with posts. I suppose they could be made to work with pages too, but that would be going far outside the scope of what the functions were originally intended to do. I think you would be better off using a plugin like Flexi Pages Widget or Sub Pages Widget, and putting those page links in the sidebar.

  11. ambrosite
    Member
    Plugin Author

    Posted 5 years ago #

    Here are the changes I have made since the initial release of the 2.0 beta:

    • Added support for custom taxonomies as per henryleo's request.
    • Added 'echo' parameter in response to ticket 13489
    • Added 'before' and 'after' parameters as per request submitted by user Hieu.

    It has been almost two weeks since I last received any bug reports or feature requests. I have also completed additional testing of my own and I am satisfied with the results of those tests. Therefore, I plan to finalize this release and upload it to the plugin directory over the weekend. My thanks to everyone who downloaded the beta version and provided feedback!

  12. AliMH
    Member
    Posted 5 years ago #

    no mate, custom post types now able to have child posts like pages.

  13. ambrosite
    Member
    Plugin Author

    Posted 5 years ago #

    AliMH,

    I did not realize you were talking about custom post types. Yes, it is possible to create hierarchical custom post types. But if you set them up that way, they are more like pages than posts (notwithstanding the fact that they are called "post" types; that is something of a misnomer, as this article explains).

    The real question is: does it make sense to talk about "next" and "previous" when the pages/posts are arranged in a hierarchy? I don't think it does. The whole concept of next and previous only works for objects that are arranged in a linear sequence. You have to sort all of the posts on some field (date, title, ID, etc) and then do a greater-than/less-than comparison against the current post, in order to find the next/previous post.

    But you cannot sort objects that are arranged in a hierarchy into a linear result set, therefore it is impossible to do greater-than/less-than comparisons. It makes no more sense to ask, "Which is the 'next' page in my page tree?" than it does to ask, "Which is the 'next' person in my family tree?" That's why there was never any "next_page_link" function in WordPress -- because the whole concept of next and previous does not work in a hierarchy.

    That is all a roundabout way of saying no, the plugin does not do, and cannot do, what you ask. However, I wanted you to understand the reasoning behind it.

  14. AliMH
    Member
    Posted 5 years ago #

    oh thats a sad news for me :(, really thanks for declarations

  15. Jeff
    Member
    Posted 4 years ago #

    Is there any way to iterate through post_types instead of categories? On my multi-author site, I'm using the More Fields and More Types plugins to set up specific post pages for my authors (Book Review, Music Review, etc.).

    In olden days, these used to be assigned a default category, but no longer. (I.e., when someone added a new Book Review post, it was automatically assigned to category 'book review', etc.)

    I'm finding that I can set up my site well enough relying solely on the post types, except here, with the next and previous links. I'd like for a book review post to show the next and previous book reviews only--the next post of type 'book-review'--but I'm not sure how to accomplish that.

    I'm not sure if this is related to henryleo's questions, above. If it is, I'm afraid I don't understand the solution. :(

    Really, all I'm trying to avoid is having my authors click "Add a new Book Review" and also have to remember to assign it to a Book Review category.

  16. ambrosite
    Member
    Plugin Author

    Posted 4 years ago #

    JMF,

    I'm not entirely sure what you're asking, but version 2.0 of my plugin does support custom post types and custom taxonomies. Have you tried installing it on your site?

  17. Jeff
    Member
    Posted 4 years ago #

    Sorry, that was confusing. (It had been a long day!) You gleaned my basic question, though; I was trying to use post types instead of categories, and not having any luck, for some reason. I found a category solution, though, and now everything is working fine! (I'm using 2.0b5, but probably just misconfiguring something.) Everything's good now, though.

  18. gendem
    Member
    Posted 4 years ago #

    Hi there,

    I have a question for you about this plugin...I hope it's an easy one.

    First, some background. I have created a custom hierarchical taxonomy that I use to filter the posts in a blog. This is done in the loop using this code:

    global $wp_query;
    query_posts(
        array_merge(
            array( 'personality' => 'geek'),
            $wp_query->query
        )
    );

    where "personality" is the taxonomy name and "geek" is the value in question. So this shows only posts flagged with the geek personality.

    Obviously next_post_link and previous_post_link don't take a taxonomy into consideration, and they also seem not to use the returned results of the loop (which does), which is irritating.

    But it led me to this plugin, and I'm wondering if it's possible to use what you have to restrict the results based on the value of a custom taxonomy? So for example, I'd like to code this:

    Get the previous post where the personality is geek.

    or maybe

    Get the previous post where the personality is not nerd.

    with "nerd" being another of the taxonomy values.

    Trying

    <?php next_post_link_plus( array(
    	'format' => '%link &raquo;',
    	'link' => '%title',
    	'in_same_cat' => false,
    	'ex_cats' => '311',
    ) ); ?>

    didn't work (note that "311' is the tag_ID of the "nerd" value).

    ...Mike

  19. gendem
    Member
    Posted 4 years ago #

    Based on an email I got from Michael, using the 'in_same_cat' => true will do the trick, and it does...but only as long as only one label is applied to a post. As soon as there is more than one, in_same_cat tries to match any of the labels applied to the current post, which is not what I'm after.

    So I'm still trying to sort this out...basically I need the opposite functionality of "ex_cats" meaning I'd like to specify the IDs to include, not exclude.

    ...Mike

  20. haveboard
    Member
    Posted 4 years ago #

    Thanks for this plugin. Just saved me an afternoon of writing the same functionality from scratch.

  21. ambrosite
    Member
    Plugin Author

    Posted 4 years ago #

    Thanks for the positive feedback, haveboard.

    Btw, the just-released version 2.2 adds a new feature called "differential exclusion" that can be used to solve the problem gendem was asking about (re: using in_same_cat with posts that are in more than one category).

    http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Ambrosite Next/Previous Post Link Plus
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic