WordPress.org

Ready to get started?Download WordPress

Forums

Post Types Order
Causes never-ending loop of previous_post_link and next_post_link (12 posts)

  1. serialboxhpc
    Member
    Posted 2 years ago #

    I have a custom post type that is set to show only 1 post per page and I am using previous_post_link and next_post_link at the bottom for navigation, kind of like turning a page.

    When I have this plugin activated it causes a never-ending loop so although I only have 6 posts, it cycles through the first 6 in the right order, and then begins choosing random posts afterward and never ends.

    I need to make this stop so that when it gets to the last post the next_post_link should disappear like it normally does without this plugin.

    http://wordpress.org/extend/plugins/post-types-order/

  2. nsp-code
    Member
    Plugin Author

    Posted 2 years ago #

    Sorry this might be a little ambiguous due to the code limitations. Only the Advanced Post Types Order contain additional tools to display the next /previous custom post type within the archive or a certain term/taxonomy. For more details you can check this post

  3. serialboxhpc
    Member
    Posted 2 years ago #

    Sorry I'm confused. Are you saying that your plugin breaks native next_post_link / previous_post_link functionality and I have to pay/upgrade in order to get it back?

    I checked out the post you linked to. previous_post_type_link() causes my site to break as does next_post_type_link

    Fatal error: Call to undefined function next_post_type_link()

    Have also tried next_couple_link() (my post type is called "Couple)

    All I am doing is having a page that loops through a custom post type and should link to each post with next_post_link and previous_post_link and when it gets to the last post, the next_post_link should disappear since there are no more posts.

    This is native wordpress functionality and it works perfectly until I enable the post types order plugin.

    Instead, after the last post, it starts grabbing random posts and goes into a never ending loop.

  4. nsp-code
    Member
    Plugin Author

    Posted 2 years ago #

    No.. i'am not saying that the plugin breaks the native next/previous.
    Just turn the Autosort to OFF and the next/previous will works like before. But you will need to use the menu_order within your queries to receive the posts in the defined order. http://codex.wordpress.org/Class_Reference/WP_Query

    The advanced version include previous_post_type_link/next_post_type_link function which helps for a better navigation through posts using the custom order, no matter the Autosort status.

    Hope it make sense.

  5. serialboxhpc
    Member
    Posted 2 years ago #

    Thanks.

    I added orderby=menu_order to my query, and disabled autosort, and this makes it worse. I have ordered the custom posts in a specific order using the plugin, and when I view them after making the above change, a post other than the first one is shown first. And odd enough, the post that is shown is neither first in the menu order, or first in the post type order. It's from the middle.

    Is menu_order going to work for a post type that is set up like "posts" and not "pages" ?

    Also after making the above change, next_post_link does not return a custom post type anymore. It returns a regular post.

  6. nsp-code
    Member
    Plugin Author

    Posted 2 years ago #

    Sorry but it appear you didn't really understand how WordPress Queries works, i suggest checking with http://codex.wordpress.org/Class_Reference/WP_Query to get a better idea about queries, and using the menu_order parameter.

    Either using the next_post_link appear to be clear for you check this link http://codex.wordpress.org/Next_and_Previous_Links. Also you can't use menu_order along with this without further codding.

  7. serialboxhpc
    Member
    Posted 2 years ago #

    I am aware of how queries work. but we shouldn't have to write more code to retain the use of next_post_link/previous_post_link. To me this looks like a bug, the fact that a never-ending loop happens. It should stop after the last post.

  8. viko74
    Member
    Posted 2 years ago #

    The previous/ next links works fine with my theme while te Autosort is off. Serialboxhpc why you may call this a bug when the author said is not implemented? I'am sure there are other nice features to have too along with reordering, i'am not blame anyone i'am aware this is free code.
    Thanks for this great plugin!

  9. serialboxhpc
    Member
    Posted 2 years ago #

    I was not asking for a feature that has not been implemented.

    Without this plugin enabled, I can use previous/next post with my custom post type without any problems. There are 6 posts. I can hit the next post link until the end, and then it stops. THat is how it is supposed to work.

    When I enable this plugin, and turn auto-sort on, I get a never ending loop of posts from my custom post type. It does not stop after 6.

    If I turn auto-sort off, then it displays nothing. It does not grab any posts from my custom post type and returns an empty array.

    As soon as I disable this plugin, it works.

    I am grateful for the free plugin and am not hear to accuse or blame. I was simply asking for help in trying to fix what to me appears to be a bug. If it can't be fixed or is not seen that way then that's fine. I can always order my posts by date.

  10. Jeroen Lam
    Member
    Posted 2 years ago #

    I had this problem also, but seems if you buy the Advanced version it solves the problems, great plugin !

  11. serialboxhpc
    Member
    Posted 2 years ago #

    Right as Ive been told however I won't buy a plugin in order to fix a bug that breaks native wordpress functionality.

  12. devotee
    Member
    Posted 1 year ago #

    I have the same issue I think. When I´m on the latest post I get a 'previous post' link which seems to link totally random. There should be no link at all there.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic