f34nc015
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Customizing preview for custom post typeHi!
Well I dumped everything I could, this id is nowhere ??Actually I missed that there are informations in the url parameters, in particular a reliable ‘preview=true’
In the end I’m sure these previews are not made to be customized at all, there a lot of scenarios, they load sometiems in different ways, …
Yes, “just working” is good enoguh sometimes, but here it makes my system a bit unpredictable. I just spent one day on a bug which was in part related to this preview things. So…
Anyway, thanks a lot for your help, it is hopefully finished now, and thanks to you.
Best, good week-end
- This reply was modified 5 years, 3 months ago by f34nc015.
Forum: Developing with WordPress
In reply to: Customizing preview for custom post typeHi!
Thanks to this object, $wp_query, I have flag ‘is_preview’ which looks reliable in the filter_content hook. So I used that and didn’t used your template solution.In some other place in the code, this flag is not reliable…
Actually, it depends if you load the preview from the button, or if you reload the page (took me some time to figure this out..!)
It’s a problem because I need to do some data validation in another place, for updating and for previewing. But I managed by just doing extra useless validation, and duplicate code..At the end it works like that.
For the preview id: nope, I never got it, except with my solution. I ran the loop, checked all the variable you mentionned: it’s just never here, only the parent id.
At the end it’s a bit frustrating, ugly, not robust… But ok
I think we are missing a simple way to do that, or wordpress misses a mecanism to deal with preview..?- This reply was modified 5 years, 3 months ago by f34nc015.
Forum: Developing with WordPress
In reply to: Customizing preview for custom post typeHi bcworkz
Thank you very much for your answer, and for fixing my post ??It works, and resolve my problem 1. Nice!
There are still 2 problems:
– this solution makes a file of my plugin out of the plugin folder, so it’s less easy for git, and less easy to distribute. I can live with it though.
– it doesn’t solve my problem 2., I still have to get the id of the post preview in a quite cumbersome way.
(I can easily get the post id of the “real” post, but not the one of this preview. I need this id to save in the meta data of the preview post (not the “real” post) the up-to-date values of the api)If you have ideas for these 2 problems?
In all case thanks a lot again for your help!