Add wp posts to cutom masonry grid

Instead of $count == 1 you should use ($count % 12) == 0, 1, and so on till 11. This gives back the remaining of the division. So if $count is 6 you would get 6, but if $count was 16 it would give back 4.

Loop and output 4 rows of posts on home page

Lets see on your structure. You have 2 block, and each block have 2 lines. First line of block have 2 posts, second line – 3 posts. See screen First we chunk array to 5 per each chunk; Next step wee need separate each array with 5 posts to 2 and 3 posts. Than print … Read more

load post data into mysql

I’m not sure of having understood what you are asking for. But if my guess is correct, you can achieve this goal by using $wpdb global variable. But, in order to be more specific, I need to know how and when you want the database to update those informations.