I am having trouble using datatable in wordpress because my software and SQL knowledge is weak. As we know acf plugin data is stored in postmeta table. I want to create a datatable. I had problems with wp_query in array index. Not all data is available. Also, as you know, it makes more sense to use server side. But how do I pull the acf values with server side and return it in a datatable. I couldn't find any good information on this. I also used the wpdatatables plugin. But it spills the whole table. I want to show the sample start_date and end_date custom fields of the post's id number. Also, some plugins create a special database for custom field values. This provides convenience. But although it makes sense for a new site, it is very difficult for someone like me who has entered a very special field value.
As I said above, is there a resource that will take the custom field values from the postmeta and post tables and return them in a server side datatable? Thanks.
PS: Sorry for my bad english.
Related
I have a challenge with the way data is stored from Wordpress into mysql.
I'm new to Wordpress - but I'm trying to combine different plugins to achieve a specific functionality on a website.
Plugin #1 uses a specific type of post and some metadata - the plugin works great.
Plugin #2 can create posts of custom types and with custom metadata from the frontend. A flexible and great plugin.
My intention is to use plugin #2 to create posts from the frontend for plugin #1, which requires that some specific metadata contains specific values (otherwise the data are interpretted wrong). These values are saved with hidden inputfields in a form.
My challenge is that a value (which is serialized) is kind of serialized again. The value is a:1:{i:0;s:3:"198";}
Plugin #2 handles it well (as the data is shown correct in front- and backend of the plugin) - BUT in myPhpAdmin I can see that the data is saved differently s:20:"a:1:{i:0;s:3:"198";}"; - and hence that value cannot be understood by plugin #1.
I'm thinking of two options:
change something so s:xx: isn't added to the value(-s)
make the frontend form/plugin save the data in a serialized way so the value gets the correct format.
Any recommendations? - can I in anyway achieve my functionality?
Looks like
s:20:"a:1:{i:0;s:3:"198";}";
value is being serialized twice. You can check the plugin source code to see why the plugin serializing same value twice and if can prevent it than both plugin can share same data.
Is it possible in Drupal to find out which user modified a particular field? Not just the whole node. After saving the content I want to display the author name next to that field.
Not sure if this is possible or not.
This is not provided by Drupal core, and (As far as I know) it is not provided by any contributed modules on drupal.org.
So, in order to do that, you would probably need to create a custom module.
A simple module to achieve that would have a database table with (nid, uid, current field value) and hook_node_presave implementation (compare field values, then update/insert/ignore saving new data to your database table).
Currently, I'm using tablepress to output different info using a table format. I want users to be able to add to existing information. I need a form in wordpress that saves user posts to these different tables. How should I go about this? Sorry if I sound stupid but I'm soft on html.
Thanks.
If you want to insert in posts table using custom form, you can use wp_insert_post().
This function inserts posts (and pages) in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. It takes an object as its argument and returns the post ID of the created post (or 0 if there is an error).
Reference : http://codex.wordpress.org/Function_Reference/wp_insert_post
I am importing a large DB from an Excel spreadsheet into a wordpress DB. I was going to do it manually by creating a new table but decided to import it into the existing wordpress framework as it will allow me to change information manually in the wordpress back end.
I was importing all 2000 rows into the wp_posts table when I realised this table doesnt have a term column. The terms are stored in other tables.
My question is... how can I import the spreadsheet into the database and keep all of the important data, especially the terms, as my site queries all information by the "term" and uses jQuery tabs to display the different terms as sub-categories.
My information looks like this:
post-title(title)---category(term)---description(content)---imageUrl---price
Note: I will create a seperate column in the wp_posts table to handle the price, or any other information I need bringing in, Im just unsure about how I can get the term information into the corresponding tables...
Thanks :)
Don't insert the data directly into the table. Call the wp_insert_post() function and pass in the correct values. It will take care of all the db dependencies.
To insert the meta data, use the add_postmeta() or update_postmeta() functions.
I am having some difficulties with my module I am currently working on. As part of this module I have created a few fields that appear on a form. This form is based in a custom entity.
First I am using field_create_field($field); to create the row in the field_config table. I am then using field_create_instance($instance); to create the row in the instance table and also create the table that begins with field_data_field.
The problem I am running into is how to remove these tables correctly at the end. I have tried manual deletion (via hook_uninstall), I've tried field_delete_field, I've tried to use the remove_instance hook that is built into the Commerce module. Either way, I end up getting lots of field_deleted_data_xxx tables being created. These don't even have data in them as I created a manual query to empty the main data tables before this function was called that seems to create these tables.
Has anyone else ever run into this problem? How do I stop Drupal from creating these tables??
You can't stop Drupal from creating them but I believe you can rid yourself of them totally using field_purge_batch and its related functions.
I really wish I knew the answer to your second question (in your comment above), my instinct would be that if you re-attach the field to the bundle then that data would become automatically available again (otherwise it really doesn't make sense to keep hold of the deleted tables) but I really can't be sure about that.