Skip Navigation

[Gelöst] Creating a taxonomy view filtered by a custom post field

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

The issue here is that the user wanted to filter a taxonomy view by a custom post field.

Solution:

Unfortunately its not possible to filter the taxonomy by the post field itself.

You will need to do a nested view to do this.
https://toolset.com/forums/topic/creating-a-taxonomy-view-filtered-by-a-custom-post-field/#post-1114427

This support ticket is created vor 6 Jahren, 2 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von guyA-2 vor 6 Jahren, 2 Monaten.

Assistiert von: Shane.

Author
Artikel
#1112137

Hi,

We have a custom post type called workshops:
versteckter Link

We are using a view in the PHP template to sort the workshops by a custom field called start-date so that the most recent appears at the top.

We have two taxonomies for our custom post: teachers and workshop categories.

We need to create a view that we can embed in our php template that allows us to show all the workshops by teachers or workshop category but ordered by the custom field start-date.

When I create a taxonomy view I can't find a way to order the results by the custom field start-date.
How to I create a taxonomy view that is ordered by our start-date custom field?

Thanks for your support!

#1112340

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Guy,

Thank you for contacting our support forum.

Unfortunately this is not possible since in order for you to order by a custom field, that custom field must be on the object that is being order.

Since this date field is not on the taxonomy then you're not able to order by that taxonomy.

Thanks,
Shane

#1112777

Hey Shane,

You mean that there is no way to create a parent and child view to get around this?

#1113066

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Guy,

I thought about a solution like that, however the issue is that 1 post can be assigned to multiple taxonomies so the display wouldn't be exactly alphabetical.

Lets say Post A is assigned taxonomy A and Taxonomy B and post B is assigned to taxonomy A and C

Now if we were to do a Parent/Child view and sort the parent view by the custom field then the taxonomy view will display this.

POST A
Taxonomy
-A
-B

Post B
Taxonomy
- A
- C

What I think you want to achieve is something like this.

Post A
Taxonomy
- A
- B

Post B
Taxonomy
- C

Now if we were to let the Parent view display only the Child view then you would get this.
- A
- B
- A
- C

Which i'm assuming would not be the desired results.

Thanks,
Shane

#1114121

Thanks for your reply Shane.

Just to clarify: we don't want the results to be alphabetical - we want to order them by by our start-date custom field (which is available only in our custom post type and not our taxonomy.

Also the way we use taxonomies on this site only one taxonomy will be applied.
For example we have workshop categories and teachers taxonomies.

In the back-end only one value will be selected for workshop categories and teachers.
So while in theory there can be multiple selections we won't be using this.

With this in mind do you think it will be possible to create a parent/child view so we can sort our taxonomies by the start-date custom field? And if so how would we do this?

Thanks!

#1114427

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Screen Shot 2018-09-24 at 10.09.01 AM.png

Hi Guy,

In this case yes it is definitely possible.

So what you will need to do first is to create the view for the taxonomy and set how you want it to display.

Secondly you need to add a query filter for the taxonomy term. See Screenshot

The next thing you need to do is to just create the parent view which will list the post and then add the taxonomy view to it.

Thanks,
Shane

#1116165

Thanks for your help! My issue is resolved now.