Support » Developing with WordPress » Ajax and WP_Query for posts

  • Hello,

    I’m developing a website with WordPress for one of my customers.
    I need to use ajax with WP_Query in order to filter posts by custom taxonomies.

    On front page WP_Query works perfectly, but on next page loading (via Ajax) the WP_Query return last post of first page and results are not filtered.

    It work for custom posts types but not for built-in posts.

    Can you help me please ?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    There’s not enough information for a conclusive solution, but it’s possible the Ajax request isn’t providing enough information for the server to make a proper query. The server has no idea on its own what page the user is on or what filters are applied, or even what post type it’s for. The Ajax must supply all necessary data to make a proper query.

    If this all works for CPTs and is failing for posts, either there’s a glitch in the code or some other plugin is interfering with the query. Most likely the latter if your code is otherwise working.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.