1

I need to get all terms that have post with dates in custom field. So I need a list for all dates from the term. I need to know exactly what is tha dates within each term in my site. It's not in term, it's in their posts.

after that I need to know foreach month what is the terms that containe post with this specifc month.

all of this is needed for search's fields to filter my post type (tours) by terms (country) and dates (each tour can have many dates).

I got the solution bymyself in another post: get terms that have post with custom post type between 2 values

Now I need to know hot to store this huge array in my Wordpress Database.

closed as unclear what you're asking by Pieter Goosen, TheDeadMedic, Howdy_McGee, bueltge, Mayeenul Islam Jun 16 '16 at 10:47

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    This is probably a bad idea and bad practice but just so readers understand, are you saying when you pass the array to update_option() it gives you a white screen or some kind of error? Can you edit your question ( by click the above edit button ) and add some more detail as to what is happening? – Howdy_McGee Jun 6 '16 at 20:39
  • I edit my question and add information – Guy Ytzhak Jun 6 '16 at 20:43
  • Why are you storing this data as an option instead of using the built-in post_meta and term_meta? – Howdy_McGee Jun 6 '16 at 20:44
  • 7
    This sounds like an XY Problem. Can you edit your question and describe how your system works and what you're trying to accomplish? – Howdy_McGee Jun 6 '16 at 20:57
  • 2
    Could you provide an example of specific user workflow? Possible solution would be significantly different depending on desired functionality and order/complexity of queries. – Rarst Jun 6 '16 at 22:03
2

In a nutshell your needs are completely unsupported by WP API.

Taxonomies in WP are a grouping mechanism. Their primary purpose is to query set of objects, belonging to a group (term) or groups. There is no reverse operation to provide a set of objects and inquire which groups (terms) it belongs to.

On top of that your logic requires additional hop to meta data and to be able to do it in both ways (restrict countries by date, as well as restrict dates by countries).

I see three possible approaches here (complexity ascending):

  1. Drop the chained requirement. Let users select date and country freely, inform them if there are no results for particular combination. Even Google sometimes says it didn't found anything.
  2. Crunch the data with API async and cache the relationship data in some form.
  3. Write custom SQL that implements the necessary logic with reasonable performance.

Personally I would go with 3 in such situation, but only because I am reasonably confident I can write and maintain such SQL.

  • Ok, I know that is not wp api support for this. So I create a function that get all of this to array, and this is a large array. so the first question is how to store and work with huge arrays. I edit my question many time to explaine it to you and I return to my first question. How to work and store big array in WP DB to display it in my site and in my custom requirements ? So why you edit my question? Its not what I need to do. I also get all this posts and terms and dates in my array. My problem is to work with huge array in regular server. – Guy Ytzhak Jun 7 '16 at 14:30
  • Options API? Not like there are that many storage options in WP. As I answered I would prefer SQL route myself, it is hard for me to estimate sane solution for intermediary caching approach without working with specific data. – Rarst Jun 7 '16 at 14:35
  • I got all the data by functions. So you think I need to work my my array? see in the question (I edit the question) or maybe I can create a CLASS and call to functions within the class foreach term? – Guy Ytzhak Jun 7 '16 at 14:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.