Hello, I have built a SQL table pulling information from a custom post type. I want to display only the primary category. Right now it is displaying a comma-separated list of all the items categories. This makes sorting by category problematic. Is there a way to only display the first item in a comma-separated list? Or any other way to clean this up? Thanks!
I can help you to manually set available values for filtering,
but to be able to split Comma Separated String Value and just pull the "first value as a substring" in the cells using SQL Query itself,
unfortunately, that would require building a custom Query, which is not included in our support.
1. Regarding setting up possible values for filtering:
- You can split the values up individually, to use in a filter, even if they are pulled together in the same cell,
here is an example.
The table pulls the values from all cells, so since you have multiple values together in one cell, it sees it as a unique value.
What you can do is open this column's settings, go to the Data tab. In there, change "Possible values for column" from "Read from table on page load" to "Define values list":
Then, in the "Values list", manually input the individual values that should be included in this column, and that's it. It should allow you to select each value on the filter, as an individual selection.
; here is the resulting filter multiselectbox of this example:
If you need more details regarding that, please contact us for further info. Thanks.
2.
Regarding customizing your SQL Query in order to Split Comma Separated String Values and just pull the "first value as a substring",
rather than pulling the entire value from your custom Post Type "categories" source column,
i am truly sorry, but that would require a high level of custom SQL Query which will not fall under the scope of what our support can cover.
You can research online to see if someone else came up with a workaround, though, on places such as Stack Overflow and similar.
I will check with our 2nd level Team if they have additional useful information or an example that might help you achieve your goal , we will report back once they advise.
Let me know if you manage to make a solution in the meantime. Thank you
Hello, I have built a SQL table pulling information from a custom post type. I want to display only the primary category. Right now it is displaying a comma-separated list of all the items categories. This makes sorting by category problematic. Is there a way to only display the first item in a comma-separated list? Or any other way to clean this up? Thanks!
https://thepinkenvelope.com/subscription-box-coupon-code/
Hi, Jonathan
Thanks for reaching out to us
-
I can help you to manually set available values for filtering,
but to be able to split Comma Separated String Value and just pull the "first value as a substring" in the cells using SQL Query itself,
unfortunately, that would require building a custom Query, which is not included in our support.
1. Regarding setting up possible values for filtering:
- You can split the values up individually, to use in a filter, even if they are pulled together in the same cell,
here is an example.
The table pulls the values from all cells, so since you have multiple values together in one cell, it sees it as a unique value.
What you can do is open this column's settings, go to the Data tab. In there, change "Possible values for column" from "Read from table on page load" to "Define values list":
Then, in the "Values list", manually input the individual values that should be included in this column, and that's it. It should allow you to select each value on the filter, as an individual selection.
; here is the resulting filter multiselectbox of this example:
If you need more details regarding that, please contact us for further info. Thanks.
2.
Regarding customizing your SQL Query in order to Split Comma Separated String Values and just pull the "first value as a substring",
rather than pulling the entire value from your custom Post Type "categories" source column,
i am truly sorry, but that would require a high level of custom SQL Query which will not fall under the scope of what our support can cover.
You can research online to see if someone else came up with a workaround, though, on places such as Stack Overflow and similar.
For example, i found this article that shows an example to Split Comma Separated String Values into Columns , perhaps it will be useful for you - https://sqlskull.com/2020/05/10/how-to-split-comma-separated-string-values-into-columns/
I hope that helps.
-
I will check with our 2nd level Team if they have additional useful information or an example that might help you achieve your goal , we will report back once they advise.
Let me know if you manage to make a solution in the meantime. Thank you
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables