So you can, in that instance stockpile production to a certain extent and when your ready, add it to a wonder.
well, you an only "stockpile" it while building science/cash/culture. As soon as you spend a turn building something the production is applied.
Its all dependent on chopping forest and whipping pop. I imagine there aren't many forest tiles left in the latter era's and by mid game you've probably switch to another civic other than slavery.
And this doesn't apply in vanilla, but in warlords and bts?
yes
Here is a link to a list of the differences between Vanilla, Warlords and BtS.
vanilla
Production from chops happens immediately on completion, no opportunity to change build target that turn
Production from chop is lost when building research/culture/wealth or when no production item is selected
And if I understand correctly if I was building a library then switched to a wonder, the production would be in stasis for the library until I either cancelled it or the wonder was built?
not quite; if you cancel the library, the invested hammers are retained. Whenever you start to build the library again, it will start partially completed.
If you have a queued unit that will experience hammer decay, the BUG/BUFFY mod will warn you.