use shortcode inside table single cell shortcode
-
how to use use shortcode inside table single cell shortcode
for example, i have a shortcode [post_title], that show the title
and i use this information in column_id_value
i type sth like this
[wpdatatable_cell table_id=”26″ column_key=”Course Name” column_id=”JUPAS Code” column_id_value= [post_title]]
but it doesnt work
-
Hello,
Can you please confirm is the value from this shortcode rendering properly/as expected in the cell of the source table back-end preview?
– Can you confirm what is the Table type ( of the source table which the value is being pulled from)?
– Are you using our Lite(free) or Premium Plugin version?
– If you can please show us more details how does the table render the value in the cell on back-end with a screenshot or a Video? ( we are not sure how you constructed the table exactly, etc)
Just make sure not to show any sensitive data here since this is a Public Support forum.
If you need to show any sensitive data from your Site, then we suggest to open a private ticket on our main Support platform.
If that is the case, or if you use the Premium Plugin version, please open a ticket on our main Support platform here, and one of our Agents will respond as quickly as possible.If you don’t have a licence (or if it expired), please open a pre-purchase ticket which doesn’t require a purchase code.
Premium products are not supported in these forums, as per this comment by ww.wp.xz.cn moderators.
Thank you for understanding.
Kind regards.
data table imported from excel
i use free version

the fifth column is what i want to render
the second column is what i want to search to locate the answer. The first six characters of my post title is JSXXXX
Hello again,
Apologies for not catching your reply here earlier.
Thank you for these details and the screenshot of the Table.
Since you use the free version, this is then a ‘table linked from Excel file source’.
And you are using our ‘second variant’ of the Single Cell Shortcode for dataTables.
So, as we have shown in the Documentation, if you go for this format as :
[wpdatatable_cell table_id=”1″ column_key=”column_name” column_id=”custom_id_column” column_id_value=”custom_id_column_value”]
That means that the column_key will be the Column in which your cell you need to render is located.
In this case, that is correct, you need a cell from ‘Course name’, right?
Just make sure to check what is the ‘origin header name’, go in the Column Display settings and use the origin header ( in case if you have a different display header name).
Now, the ‘column_id‘. It is the name of the column that contains unique values (origin header name* of the column)
Then, the column_id_value – is the value from column_id column which tells the table which row to look for.
So you need to give it a unique value in column_id_value to pinpoint which row from Column “Course Name” you need in your single cell value.
Let’s say if we wanted to pull cell value in your table from Column Course Name to be this row which has “Anthropology” ( and some special letters which I can not write due to language barier) showing on your screenshot, I will highlight it in my image :
In this case, your Single Cell Shortcode will be :
[wpdatatable_cell table_id=”26″ column_key=”Course Name” column_id=”JUPAS Code” column_id_value=”JS4006″]
And that would pull up the “Anthropology” cell value in your Shortcode.
Let us know if this points you in the right direction to solve the issue?
If you still can’t solve it, can you show us a screenshot when you have the value/row you need showing in the table and how it looks;
What is the value for that specific row in “JUPAS Code” and what is the value in “Course Name”?
You can also send us your source Excel file so we can make a table from it to show you an example how to pull the specific cell you need.However, the JUPAS Code is another shortcode which is [post_title] in my post which grab a certain characters from the title of the post. In this way, it is easier for me to scale the content.
That’s why i type [wpdatatable_cell table_id=”26″ column_key=”Course Name” column_id=”JUPAS Code” column_id_value= [post_title]] at first
and my struggling point is that how to use shortcode inside a shortcode
Hello again.
What you’re trying to achieve can be accomplished only with the use of Filters (hooks). Here’s how it can work:
function filterColumnIDValue( $columnIDValue, $columnKey, $rowID, $columnID, $table_id){ // For specific table id - in your case 26 if ($table_id == 26) { // Filter for specific name of the column that contains unique values (origin header* of the column) - in your case 'JUPAS Code' if ($columnID == 'JUPAS Code') { // Filter for specific column ( origin header* of the column)- in your case 'Course Name' if this is the orig header if ($columnKey == 'Course Name') { $columnIDValue = do_shortcode("[post_title]"); } } } return $columnIDValue; } add_filter('wpdatatables_cell_filter_column_id_value','filterColumnIDValue', 10, 5);Please let us know if that helps.
Hello
it has been a long day.
After a month, I finally have time to deal with this thing again.
Can you please explain again what the code does?
Since i am no very good at coding
Hello sharsharshar,
Basically, we don’t have any built-in solution to achieve your use-case.With our built-in ‘out of the box’ options for the Single Cell Shortcode, it is not possible to use a ‘shortcode inside a shortcode’ as you described.
You would need to insert the actual value from your cells as explained on our Documentation examples/tutorials and the initial example we gave.You can suggest this for future development, though – our developers will do their best to make a built-in solution in the future.
Please feel free to search on our suggestions page (https://features.wpdatatables.com/), to see if someone may be already suggested this feature. If you can’t see it, feel free to add your suggestion there, and as more people vote, the feature will move higher on the priority list.
You can certainly follow our changeLog if you’d like(https://ww.wp.xz.cn/plugins/wpdatatables/#developers), where we state any changes/new features/bug fixes during updates;
and our newsletter(https://wpdatatables.com/newsletter/), so you’re informed about new features, bug fixes, freebies, etc.
If you have coding skills and wish to try to make a custom solution now, the custom workaround example we sent is the only way to achieve it at the moment.
As we pointed out in our Documentation section regarding hooks/filters :
Please note that using hooks requires a certain level of programming skill, and our support is limited to only advice with an example.
We are unable to offer a detailed tutorial or explain each step of the code. Our developers have provided an example, which is the extent of our assistance, as they are currently focused on major tasks for plugin maintenance and are unable to undertake custom work.
Thank you for your understanding.
We hope that helps.
Kind regards.I think at least tell me where the code should be placed
-
This reply was modified 1 year, 11 months ago by
sharsharshar.
-
This reply was modified 1 year, 11 months ago by
sharsharshar.
Hello,
You will find various tutorials online on the subject of how to use hooks in WordPress.
For example, here is one from wpBeginners.
You will also find this introduction from our developers on our Hooks Documentation :Filters (hooks) in WordPress are a type of callback functions that can be defined by the user, and are applied to certain values – strings, integers, objects, etc. It is a simple way to adjust code output without actually having to modify the code. Essentially, you add a given function on top of an existing one, to override the logic. Then, when the plugin is updated later, you won’t lose any of your changes.
You can get a detailed description on WordPress hooks here in WP Codex.
That being said, one of the ways how you can add your code/custom function is to add it to your functions.php of the current WP Theme or Child Theme.
This won’t be affected by wpDataTables updates since you are saving it outside of our Plugin’s files.
Please note that using hooks requires certain level of programming skills and included support refers only to advice.
I hope that helps.
Kind regards. -
This reply was modified 1 year, 11 months ago by
The topic ‘use shortcode inside table single cell shortcode’ is closed to new replies.