Hi, I have a custom post type "Classes", which has a unique post_id. On the Classes archive page, I am able to click the post and show an edit custom post page. At the bottom of this edit page, there is wpDataTables grid by using VAR1 as the selection parameter (WHERE post_id=%VAR1%). I setup VAR1 as the post_id at the back end PHP.
Display is not a problem, when it come to add new entry, I am not able to set the post_id default to VAR1 (and user should not be able to change this default). Is there a way to do this?
I'm not sure I understand, but what I understood is that you cannot add %VAR1% as a predefined editing value? Have you defined %VAR1% in the Placeholders tab above the table? If you did, and you added it to the column's predefined value, editing the row or adding a new one should populate the column with the value you added in %VAR1% in the Placeholders tab above the table.
SELECT wp_wpdatatable_1.`wdt_ID`, wp_wpdatatable_1.`classname`, wp_wpdatatable_1.`classdate`, wp_wpdatatable_1.`classolddate`, wp_wpdatatable_1.`classattendance` FROM wp_wpdatatable_1 WHERE 1=1 AND wp_wpdatatable_1.`classname` = %VAR1%
as the data source.
wdt_ID is the primary key and I am not worry about it. 'classname' is the post_id. I have to fill 'classname' default to VAR1 that I pass to the query. It has to work either Edit or Add.
My question is what is the best way to handle this?
If we understood you well, you could use %CURRENT_POST_ID% placeholder instead of %VAR1%, and you wouldn't need any custom code on the page. The only thing you need to do is add our shortcode, and in the query the placeholder will be replaced with the current post ID.
If that's not what you want to achieve, please explain in a bit more detail, or send us a video explanation.
I am using OceanWP/Elementor pro/ACF Pro on my Wordpress site. Let's see if I could explain this:-
I have a custom post with a few ACF, I am using ACF Frontend to handle that. Under this post, I have a database table, I use the data like a repeater field in ACF. My reports mostly based on this table so I decided to use a table instead of ACF repeater. I am using a single post template to display/edit this custom post.
Here is my query definition:-
SELECT wp_wpdatatable_1_1.`wdt_ID`, wp_wpdatatable_1_1.`classname`, wp_wpdatatable_1_1.`classdate`, wp_wpdatatable_1_1.`classolddate`, wp_wpdatatable_1_1.`classattendance` FROM wp_wpdatatable_1_1 WHERE 1=1 AND wp_wpdatatable_1_1.`classname` = %CURRENT_POST_ID%
wdt_ID: non editable, non displayable <-- this is primary key and user don't need to see this
classname: non editable, non displayable <-- this is the post id, always be the current post, and I don't want user to see it nor change it.
I put a number in the %CURRENT_POST_ID% placeholder because I need that for development.
The above setup doesn't work. When I add a new record via the "new entry" button, the new record carry the placeholder's value, instead of the current post id.
To workaround this, I have to set classname editable/non disaplyable. At this point, the newly created DB record will have the current post id fill in. The problem is "new entry" modal will display the placeholder value instead of the current post id. And user could change the value. That confuse the user a lot!!!
I would not put this as a show stopper, but it certainly is an issue.
Yeah, if the classname is an editable field, it will appear in the edit modal. The only thing I can do here is find the CSS code behind it, and provide you that CSS, so you can hide the field. However, you should know that predefined editing values disappear if you click on "Apply and Add new", so that should be removed also.
Hi, I have a custom post type "Classes", which has a unique post_id. On the Classes archive page, I am able to click the post and show an edit custom post page. At the bottom of this edit page, there is wpDataTables grid by using VAR1 as the selection parameter (WHERE post_id=%VAR1%). I setup VAR1 as the post_id at the back end PHP.
Display is not a problem, when it come to add new entry, I am not able to set the post_id default to VAR1 (and user should not be able to change this default). Is there a way to do this?
Hi Terrence
I'm not sure I understand, but what I understood is that you cannot add %VAR1% as a predefined editing value? Have you defined %VAR1% in the Placeholders tab above the table? If you did, and you added it to the column's predefined value, editing the row or adding a new one should populate the column with the value you added in %VAR1% in the Placeholders tab above the table.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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
Hi, On wpDataTables panel, I have VAR1 default to 270. 270 is a custom post id for testing.
I pass the post_id from URL, something like :-
http://test.local/test-1/?post_id=282
282 is another working post_id I pass to test-1.
I have :-
//----------------------------------
<?php
if (isset($_GET['post_id'])) {
$thepost_id = $_GET['post_id'];
$thispost = get_post( $thepost_id, OBJECT );
echo '<p>Editing ' . $thispost->post_title . '</p>';
echo '[wpdatatable id=3 var1=' . $thepost_id . ']';
echo '<div id="thispostid" style="display: none;">' . $thepost_id . '</div>';
} else {
echo '<p>No Class Data</p>';
}
//----------------------------------
to display the table grid. I have :-
SELECT wp_wpdatatable_1.`wdt_ID`,
wp_wpdatatable_1.`classname`,
wp_wpdatatable_1.`classdate`,
wp_wpdatatable_1.`classolddate`,
wp_wpdatatable_1.`classattendance`
FROM wp_wpdatatable_1
WHERE 1=1
AND wp_wpdatatable_1.`classname` = %VAR1%
as the data source.
wdt_ID is the primary key and I am not worry about it. 'classname' is the post_id. I have to fill 'classname' default to VAR1 that I pass to the query. It has to work either Edit or Add.
My question is what is the best way to handle this?
Thanks
Hello Terrence
If we understood you well, you could use %CURRENT_POST_ID% placeholder instead of %VAR1%, and you wouldn't need any custom code on the page. The only thing you need to do is add our shortcode, and in the query the placeholder will be replaced with the current post ID.
If that's not what you want to achieve, please explain in a bit more detail, or send us a video explanation.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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
I am using OceanWP/Elementor pro/ACF Pro on my Wordpress site. Let's see if I could explain this:-
I have a custom post with a few ACF, I am using ACF Frontend to handle that. Under this post, I have a database table, I use the data like a repeater field in ACF. My reports mostly based on this table so I decided to use a table instead of ACF repeater. I am using a single post template to display/edit this custom post.
Here is my query definition:-
SELECT wp_wpdatatable_1_1.`wdt_ID`,
wp_wpdatatable_1_1.`classname`,
wp_wpdatatable_1_1.`classdate`,
wp_wpdatatable_1_1.`classolddate`,
wp_wpdatatable_1_1.`classattendance`
FROM wp_wpdatatable_1_1
WHERE 1=1
AND wp_wpdatatable_1_1.`classname` = %CURRENT_POST_ID%
wdt_ID: non editable, non displayable <-- this is primary key and user don't need to see this
classname: non editable, non displayable <-- this is the post id, always be the current post, and I don't want user to see it nor change it.
I put a number in the %CURRENT_POST_ID% placeholder because I need that for development.
The above setup doesn't work. When I add a new record via the "new entry" button, the new record carry the placeholder's value, instead of the current post id.
To workaround this, I have to set classname editable/non disaplyable. At this point, the newly created DB record will have the current post id fill in. The problem is "new entry" modal will display the placeholder value instead of the current post id. And user could change the value. That confuse the user a lot!!!
I would not put this as a show stopper, but it certainly is an issue.
Thanks
Hi again Terrence
Yeah, if the classname is an editable field, it will appear in the edit modal. The only thing I can do here is find the CSS code behind it, and provide you that CSS, so you can hide the field. However, you should know that predefined editing values disappear if you click on "Apply and Add new", so that should be removed also.
You can see how to remove that here.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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