- This topic has 3 replies, 2 voices, and was last updated 1 year, 6 months ago by .
My apologies for asking about something that is probably something very elementary.
But I'm a little confused and would like to know the most efficient way of doing the following:
I've created a cpt called "Customer File".
The title of each post is the customer #.
Each post has 3 custom fields:
So, I'm working on an archive or Search Results type of page.
The page is called Monthly Invoices.
The invoices are not posts or custom posts that are retrieved the normal way (that is, with wp_query & displayed by going through the loop.)
Instead, my code makes an api call to a remote server that returns an array of invoices for the requested month.
So, my code loops through the array of invoices (using foreach) & outputs the invoice data for each invoice.
Each element of the array is an invoice that contains invoice data, but the only customer info is the customer #. So, I need to get the post from the "Customer File" cpt where the title of the post matches the "customer #" of the invoice (that I got from the api.) & then display the values for the "name", "address", "phone" custom fields of that customer post.
So, as I'm looping through the "Invoice" array, what's the right way to take the $customer_number field in the array, retrieve the corresponding post in the "Customer File" cpt & display the values of the 3 custom fields?
I hope I've explained this clearly.
- You must be logged in to reply to this topic.