WordPress.org

Ready to get started?Download WordPress

Forums

Finding the Next Post in a WP_Query in Single.php (6 posts)

  1. faeronsayn
    Member
    Posted 1 year ago #

    So basically I want to find out the post that's after the post that I am currently on by using the creation date.

    Possibly through WP_Query using the following arguments

    // Find connected posts
    $episodesAnime = new WP_Query( array(
      'connected_type' => 'posts_to_anime',
      'connected_items' => get_queried_object(),
      'nopaging' => true,
      'order-by' => 'date',
      'order' => ASC,
    ) );

    With a while loop I can get all the posts that I want. Now I want to make it so it only shows the posts that are ahead and behind the actual post that the user is currently on.

  2. faeronsayn
    Member
    Posted 1 year ago #

    Any sort of help or direction would be appreciated.

  3. keesiemeijer
    moderator
    Posted 1 year ago #

  4. faeronsayn
    Member
    Posted 1 year ago #

    All of these look for a category to restrict their search, I want the aforementioned query to restrict my search.

  5. keesiemeijer
    moderator
    Posted 1 year ago #

    “connected_type” or “connected_items” are not built-in parameters:
    https://codex.wordpress.org/Class_Reference/WP_Query#Parameters

    Do you use a plugin for these parameters? If so, post in the dedicated forum for that plugin.

  6. faeronsayn
    Member
    Posted 1 year ago #

    Alright then.

Topic Closed

This topic has been closed to new replies.

About this Topic