Skip Navigation

[Resolved] courses sites

This support ticket is created 7 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 7 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#431488

Here is the scenario:

I am creating an school site. The school offers different courses, and each course has a Teacher and different dates of delivery.

So far, I created a CPT for Teachers, and for Curses.

They both share a Taxonomy of "Course-Key" so that I can link a teacher to a course in a Content Template.

The dates for each course I created a Repeting Date Filed in the Courses CPT.

Now, Problem 1:

In a View, I want to show the 3 next availabel courses. I limited the query to 3 results, however using the For Each variable, I am getting all the dates of the first 3 courses ordered by date. So If course 1 has 4 dates and course 2 has 5 dates, and course 3 has 2 dates, In the results, I am getting 11 results!! Not 3.

How can I limit the results to 3 results ONLY including the For Each Results? And Still ordered by date, but excluding past dates from "today"?? 🙂

Problem 2,

In another View for the same content template, I want to query other courses the same Teacher delivers. I cannot figure out how to do that query.

I am getting the teacher info, in another View where I query the Teacher based on the "Course-key" taxonomy. And this works fine.

Now I want to print other courses by the same teacher, but cant figure out how to query them. 🙂 Any ideas?

#431677

Dear peter,

Q1) What is the "the For Each variable" you mentioned above?
Is it Views shortcode [wpv-for-each]?
https://toolset.com/documentation/views-shortcodes/#wpv-for-each
If it is, according to above document:
Note: wpv-conditional shortcode won’t work inside a wpv-for-each shortcode
So it is not possible to use [wpv-conditional] to compare the custom date field value with "today"
I suggest you setup a new post type "courses date" as child post type of "Curses",
setup the a single instance date field "date" in post type "courses date",
Then display the result with a nested view
1) Parent view list "Curses" posts,
2) Child view list "courses date" post, filter with:
a. Post relationship – post is child of Post where this View is shown
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
b. custom date field "date" value is large than "today"
https://toolset.com/documentation/user-guides/date-filters/\

Q2) What is the "same content template", if it is in single "Teacher" post, you can create a view list "courses" posts, filter with:
Value set by the current page where this View is shown
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/
The View is always inserted somewhere. That page where the View is inserted is responsible for setting the taxonomy term. This is good when you want the same View to return different results, according to the page it’s inserted to.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.