Skip Navigation

[Resolved] Grouping posts together according to their ID or post title

This support ticket is created 5 years, 3 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 5 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#1189242

Lee

Group posts together according to their ID or post title

Is there any documentation that you are following?
No

Is there a similar example that we can see?
hidden link

What is the link to your site?
hidden link

#1189543

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2019-01-23 at 07.25.02.png

Hi Lee

I see you were chatting with Christian about this, but the thread is in the unassigned queue, so let me help out.

Before I noticed your chat I looked at the link you shared and got the gist of what you need, and the solution I was going to suggest was to use a numeric custom field.

In your question you ask about using the ID or the title, but when it comes to filtering a View to find posts that have numbers within a certain range then custom fields are really the only option.

See my sample screenshot, where I'm specifying the top and bottom of the range I want to return with shortcode attributes, but you could equally use URL parameters, for example.

You say that you imported the data such that the post ID was the same as the pottery ID. That sounds dangerous as a strategy, because if new posts are published it could interfere with your scheme, but it does suggest that you were already able to isolate the numeric part of an ID such as A1067, which is what you need to do.

So, a pre-requisite of being able to handle this in any remotely sensible way is that you can import the data so that it has a custom field that stores the numeric value.

Is that possible?

#1189549

Lee

Good morning Nigel,

We're importing from a spreadsheet and using WPAllImport, so I'm pretty sure it's possible to do what you're suggesting. We already have a CPT for 'Patterns' with the fields that we need to store the data for the font end, so is it simply a case of creating a new field to store the pattern number again? Also, how will this approach handle the numbers that start with a letter A1001 for example?

Thanks for you help with this.

Lee

#1189615

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Well, how do you want to treat patterns such as A1001?

If people are searching for/browsing patterns, should that be treated as if it were "1001"?

Might there be duplicates, e.g. a "1001" and an "A1001"?

#1189618

Lee

Hello again Nigel,

Yes indeed, there are many that share the same number but have a preceding letter! Any ideas?

Lee

#1189624

Lee

Ideally we'd like to keep the same sort of indexing system as can be seen here...

hidden link

Not sure if it's possible though?

#1189845

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

OK, sorry, I didn't spot that there was a mix with and without letters.

That gets more complicated.

If you were able to prepare the data such that the custom field was populated with a fixed number of characters then you might be able to do this with a string comparison rather than comparing as a number.

Let's worry about simply being able to query the posts between certain ranges first, before worrying how to enter the range to be queried too much.

If you were to compare as numbers then

1119 > 987 > 122

But if you compare the same as strings you would have

987 > 122 > 1119

Which you can fix with

1119 > 0987 > 0122

And which you can also introduce numbers with, e.g.

A1119 > 01119 > 00987 > 00122

So, might that work? Your post titles are the numbers and or letter-numbers as required, but the custom field which is used to order and filter the posts is a fixed length string with front-padding as required.

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