Forum Replies Created
-
AuthorPosts
-
SaraParticipantOooops… my bad, removing the ‘scope’ did the trick 🙂
SaraParticipantHello everybody,
I’m bringing this post up…
I’m wondering if this option is now available, because I’m trying to upload some pictures for logos in my footer, and it doesn’t seem to work.
Am I doing something wrong or is this option still to be implemented?
Thank you 🙂
SaraParticipantHi Jason,
I’m back to tell how I succeeded making work my query into my custom api 🙂
I was totally blind on this: I just had to make my query relate with the ID of the results in my json.
*facepalming myself*$events_query = new WP_Query(array( 'suppress_filters' => false, 'post_type' => 'event', 'numberposts' => -1, 'post_status' => 'publish', 'relate_query' => array( array( 'id' => $results['cities'][0]['id'], 'relate' => 'has' ) ) ));Thank you for your help 🙂
SaraParticipantHello Jason 🙂
Thank you for the XDebug advice, I didn’t know about it.
I’m currently trying to get it work on Atom…So… well, yes I’m creating a custom rest api endpoint.
And no I don’t extend anything with WP_REST_Posts_Controller (I wasn’t even aware of it by now).
I’ve registered a custom rest route, added my action and created my function which works as expected for other out of Piklist queries. So far, I’m using Postman to test my api queries results.And yes, that exact query works well outside of the REST API, with both
'relate_query'or'post_has'and aforeachfor the front end. Each city page displays the correct associated events.I’ll come back to let you know after I’ll test it out with XDebug.
If you ever come with some idea about this, don’t hesitate to drop me a line.Thank you very much 🙂
SaraParticipantHi Jason,
Thank you for replying 🙂
I got a little React training some months ago, I’m looking forward to getting back to it, I really loved it 🙂
But here, I had tried
'relate' => 'belongs'already, but with same results.
If I use'relate_query'nothing happens, and if I use'post_belongs' => $post->IDall 4 events are pushed in the array :\Scratching my head…
SaraParticipantThanks Jason,
Sorry for the late reply, got to dive into something else for a while.
Gonna try to solve this out with a fresh mind 🙂
Yes, I also think it must certainly be something simple.Thank you for your patience, and improving the documentaion 🙂
EDIT
Did a fresh install and all went great!
I’m really going to LOVE Piklist! 🙂
SaraParticipantHi Jason 🙂
Thank you very much for taking the time to explain me. It helped understand better how it all works, which makes sense actually (about choices, IDs and titles).
The scope explanation was indeed enlightening.So, yes I began working on this with the tutorial relationship example, but as it didn’t work, I suspected I didn’t understand (no surprise).
'field' => 'city_event'
I added this because after selection, the data didn’t seem to be stored. I applied the changes you adviced, but again, once I select a city, the select box returns to the 1st value in the list 😐attributes' => array('multiple' => 'multiple',)
I removed the ‘multiple’ attribute because I didn’t want multiple city choices, only one – correct?Now my print_r($related_events) still display my 4 events.
I tried to foreach, var_dumped all I thought about. Still doesn’t work.
It always retrives my 4 events unsorted.I also tried moving my CPTs out of my mu-pluings folder in functions.php file, but it didn’t help either.
I ended up pasting your entire code to be sure, still not working.I really wonder what I am missing here…
SaraParticipantHi Steve,
Sorry for being late to thank you for your answer.
I got it to work by setting the Unix timestamp to default, updating my dates in the posts, and finally using the WP internationalization.$date = get_post_meta($post->ID, 'event_date', true); $new_date = date_i18n("d M Y", strtotime($date)); echo $new_date;
SaraParticipantOk spoke too soon…
I still can’t strttotime my date without it being reset to 1970.
Tried to edit the value and dateForat, nothing helped.Anyone?
SaraParticipantIt’s ok, got it with the Unix timestamp… duh!
Love this plugin btw, thanks for the great job 🙂 -
AuthorPosts