Where is the order of a menu saved in the database

You will get the nav_menu_items from wp_term_relationship in correct order. if you want to confirm there order by knowing there order number… u will get the object id of each item from the previous table and search for that id in wp_posts. then there will be column for that particular row named menu_order. so that … Read more

Create page with custom php script and fetched data

1) It is easy to create tables in WP. I suggest making a plugin to handle this for you. See the codex for more info: https://codex.wordpress.org/Creating_Tables_with_Plugins 2) Again, I suggest using WP to handle this for security purposes. As you stated, you would have connection details that could potentially be exploited. 3) I think there … Read more

List of ways to access WordPress database?

There’s some overlap, but each isn’t an abstraction of the previous, and there are definitely some things you don’t want to do outside of the API. Most things, actually! WP_Query is for retrieving posts and pages, it doesn’t update anything, and it doesn’t fetch data that isn’t a post or page. The higher level API … Read more

Custom WordPress Table wpdb

First off, you should not be handing an untrusted input (in this case, $_GET[‘id’] to your database. Always SQL-escape the query and validate/sanitize the data. (In the code snippet below, it’s SQL-escaped using $wpdb->prepare() for escaping and int typecasting to sanitize to integer value). Secondly, the $wpdb object provides more than just the query() function. … Read more

Execute a function every hour in the background

I setup something similar. Using IIS – look into writing a .bat file which fires off a php shell script to do whatever it is you need to accomplish. once you have that bat file working, setup a “scheduled task” in IIS http://technet.microsoft.com/en-us/library/cc721871.aspx if you are on a linux system, then use crontab https://www.freebsd.org/doc/handbook/configtuning-cron.html If … Read more

$wpdb->query can’t insert data

The following code will properly store data in wp_fafa: $wpdb->insert( $wpdb->prefix . ‘fafa’, array( ‘title’ => trim($row->item(0)->nodeValue), ‘liveprice’ => trim($row->item(2)->nodeValue), ‘changing’ => trim($row->item(4)->nodeValue), ‘lowest’ => trim($row->item(6)->nodeValue), ‘topest’ => trim($row->item(8)->nodeValue), ‘time’ => trim($row->item(10)->nodeValue) ), array( ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’ ) );

Save and user submitted data from a form and display them in the wp backend

Can you just tell me how I can grab the input value for “name” and add the entry to custom_post_type? Sure thing: if ( isset( $_POST[‘name’] ) ) { $name = sanitize_text_field( wp_unslash( $_POST[‘name’] ) ); if ( $name ) { wp_insert_post( array( ‘post_title’ => $name, ‘post_type’ => ‘my_post_type’, ‘post_status’ => ‘publish’, /* Or “draft”, … Read more

how to read database fields

Those are php serialized constructs. The one you have there is an array. If you are looking to read them as a human, it breaks down like this: Array: a:size:{key definition;value definition;(repeated per element)} String: s:size:value There are other possibilities that you can read more about here. Generally, you should never modify these directly since … Read more