« first day (2832 days earlier)      last day (2101 days later) » 

11:34 AM
@TomJNowell done
 
Did everyone give a proper goodbye to Yahoo! Messenger?
 
@JackJohansson dude! Been awhile, hope ya been well. Never used it like I never used Skype =P
 
@Mᴏɴᴋᴇʏ Hey man! I'll be doing well if I make it through summer :P How about you?
I actually used it within 2001 and 2010, was kind of cool
 
@JackJohansson trying to decide wether WP will be a good fit to host info for an APP.
 
You planning to only use the API?
 
11:45 AM
I've written a shell script using jr I'm debating setting up on my server and then pushing it to a an AWS account for hosting the API
@JackJohansson well a custom built backend so I dont have to re-invent the wheel
so the WP would be a landing page for the app and then also serve content to the app
 
Oh if you want the back-end too then WP is good :P You already know it too
 
since WP is also going to be serving images I think I've settled on cloudflare for my CDN
@JackJohansson ya but the return of 100 only posts is going to be an interesting task to build for.
 
I'm actually planning to move away from WP after gutenberg, so I'm trying hard to use it as much as possible while I can :P
Why not build your own endpoint?
I never used the built-in endpoints
 
@JackJohansson I thought about that but still too many questions and not a lot on how to.
@JackJohansson thats where this came from when thinking that: wordpress.stackexchange.com/questions/283948/…
 
It's easier than you imagine, are you familiar with JSON?
 
11:49 AM
but never got an answer
@JackJohansson ya I use it a lot in other languages
 
It's one of those opinion based questions :P
Btw you don't need to @ me I'm the only one talking here xD
 
lol, it's not an opinion to kill an endpoint =P
that's a habit, lol
 
I would simply add a deprecated true/false in my response though
and check it on my app on each request
then if the api was deprecated, the app would look for a new URL already included in the response
 
then make a custom splash page with a shark eating the page to push the user to update
 
11:53 AM
this is cool but when doing a demo at a WP Camp I think it should be required to provide a repo: youtu.be/AcbClojfA8I
did you say you can control the return count in a custom endpoint? Have a sample of that?
 
I actually use Amazon Web Service in conjunction with WP this way
GUI-Less
 
@JackJohansson oh nice. havent used AWS yet how you like it?
 
You can return anything in custom response, maybe there's a limit in the response size ( by bytes, but I'm not sure )
@Mᴏɴᴋᴇʏ I just use it to send email to the customer after their purchase, but it gives a lot of options
@Mᴏɴᴋᴇʏ Ya lemme write one
 
dont have to ping me, lol =P
 
wasn't ping, was reply :P
OH
I noticed xD
 
11:57 AM
ha ha all good
 
So when you reply, it shows as ping for the reception. Tricky!
 
should have my new theme up that uses React... man that has been a challenge
 
function rest_query(){

  // Query all posts
  $query = new WP_Query( [ 'posts_per_page' => -1 ] );

  // Create an array of post IDs for the response
  $response = [];

  if( $query->have_posts() ) {
    while( $query->have_posts() ) {
	  the_post();
	  $response[] = get_the_ID();
	}
  }

  return $response;
}
Something like this should return the ID of every post published
 
@JackJohansson that's an interesting approach and may be beneficial in a custom post type with custom endpoint
 
I like to write everything myself to suit my needs, so I write all of the endpoints that I need
 
12:06 PM
I do too but I'm OCD on testing
could this be closed as a duplicate for this
 
 
3 hours later…
3:14 PM
such a query could also be very expensive
a more appropriate mechanism would be pagination
the query has no upper bounds, and it fetches the entire post not just the ID, memory and time constraints mean it would fail once the amount of content or server load reached a certain point
 
 
3 hours later…
6:04 PM
@TomJNowell can you explain a little better?
 
6:30 PM
If you just need ids why not just request IDs with fields => 'ids'?
That'll automatically skip post caching and it returns an array of what you need. I would refine it further by only requesting to look at published post_status => 'publish'
 
 
4 hours later…
10:48 PM
@Mᴏɴᴋᴇʏ the same way the posts endpoint only returns the first page, with headers to identify how many pages and which page you're on
it's all in the official docs
also +1 to specifying post status
in fact yes you don't need a custom endpoint at all, the official core endpoints return 100 because they rely on pagination
just request the second page of results
it even explains why 100 is the limit
 
11:20 PM
@TomJNowell ah good points. Will need to decide how I want to build a file
 
11:45 PM
Stack Exchange updates: The comment flag and comment up-vote icons were made visible by default rather than visible on ho
posted on July 18, 2018

The comment flag and comment up-vote icons were made visible by default rather than visible on hover.

 

« first day (2832 days earlier)      last day (2101 days later) »