I need to run a AJAX Fuction from within a WP_Query but only works on first item

The problem is with the element id you are taking.

Because if page has multiple ids with the same name (e.g apftitle). Then it will work for the first element only because it search for the first occurrence of id and work for it only

  1. You can solve it by keeping the ids dynamic so it will work for all.
  2. Or you can use the javascript’s this pointer which refers to the current element with which it is attached.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)