If WP custom field contains a value create a hyperlinked entry, else make it plain text.
If WP custom field contains a value create a hyperlinked entry, else make it plain text.
stimpygato
Posts: 4Questions: 2Answers: 0
This is on a WordPress site, and I have a column returning a name hyperlinked to its own post_ID page.
But, I want it to be plain text if a custom field named "Private" has a value of "yes".
I'm not sure how/where to do this, and any gentle nudges in the right direction would be greatly appreciated!
"columns": [
{ "data": "post_title" },
{ "data": "city" },
{ "data": "website" },
]
This discussion has been closed.
Answers
You can change the display in a column with the columns.render option.
https://datatables.net/reference/option/columns.render
This example shows how to merge multiple data fields into a single column
http://datatables.net/examples/advanced_init/column_render.html
ThomD, thanks very much for the suggestions. Looking back. I think my question wasn't clear enough.
I have a JSON file, which is supplying the tabular data via an AJAX request.
The variable I'd like to compare is a WordPress PHP variable ('food-status') that is not present in my JSON file.
I'd consider manually adding them, but its a list that has 18,000+ entries, and I don't know a good way to automate it.
If I tried to call a function from within the DataTables script, wouldn't my PHP var be outside the DataTable's scope?