How to configure DataTables, pulling from a database

How to configure DataTables, pulling from a database

parker.sorensenparker.sorensen Posts: 10Questions: 2Answers: 0

This is my first time using DataTables, and I am struggling to configure it properly. I have the data in my table pulled from database (wordpress custom posts). I have 25 posts, but only 10 appear, and when I click to show 25 entries, it stays at 10. It also only sorts and searches the current page, and says, "Showing 1 to 10 of 10 entries".

I added some default WP pagination to it for testing, and can go between pages. But, each page acts like it is separate from the others, meaning they sort and search independently, and never show more than 10 rows.

If I put all the rows in the HTML/PHP page, they sort, search, and function perfectly. It is just when I have them pulled from a database (MySQL) that I run into problems. Has anyone else faced this, or know what might be causing this?

Unfortunately, I cannot give a live example, since this is on an intranet site. I have copied the code into a codepen project though. It does not work, as it is not pulling from the database. Here is it:
http://codepen.io/parkersorensen/pen/EyjwBe

Thanks in advance

Answers

  • parker.sorensenparker.sorensen Posts: 10Questions: 2Answers: 0

    I figured it out... I had my query in functions.php set to display 10 items per page. I set it to pull all items (changed value from 10 per page to -1). Works great now!

This discussion has been closed.