Query the links Database

WordPress adds prefixes to tables names, which was setup on installation. So by default there is wp_ prefix for tables names. It means that by default table name for links will be wp_links. But you shouldn’t care about standard tables name, because all of them exists as parameters of wpdb class (read Table section), so … Read more

wp_list_table multiple checkboxes

I came up with this…I changed input fields to <input type=”checkbox” id=”%2$s” name=”post[%2$s][]” value=”%2$s” /> <input type=”checkbox” id=”image_%3$s” name=”post[%3$s][]” value=”%2$s” />’ …and added third parameter to column_image function ($item[‘ID’]) function column_image($item){ return sprintf( ‘<input type=”checkbox” id=”image_%3$s” name=”post[%3$s][]” value=”%2$s” />’, /*$1%s*/ $this->_args[‘singular’], /*$2%s*/ ‘yes’, /*$3%s*/ $item[‘ID’] ); } and with that I get array which use … Read more

Get user ID when action row link is clicked

I am passing the user ID as user via the link so its show in my custom list table url. For example, admin.php?page=history_logger&user=3 The user ID is in the query variable. You can access it using a PHP global variable. $_GET[‘user’] $user_id = $_GET[‘user’]; Do not assume that this request (link) came from the Users … Read more

When sorting WP_List_Table, table sorts, but I also get SQL errors

the part ORDER BY $orderby $order LIMIT get translated to ORDER BY asc LIMIT, the columnname that supose to be in $orderby is missing, and there for the sql fail. looks like you want your default value to be ‘title’ $orderby = (isset($_REQUEST[‘orderby’]) && in_array($_REQUEST[‘orderby’], array_keys($this->get_sortable_columns()))) ? $_REQUEST[‘orderby’] : ‘title’; may geuss is that in_array() … Read more

Let Posts be stored in another table

Use save_post action hook as shown below but write custom insert/update queries to save information in a different table. add_action(‘save_post’, ‘save_product_data’); function save_product_data($post_id) { //verify nonce and all other code… $title = $_POST[‘post_title’]; //example variable $wpdb->query( $wpdb->prepare( ” INSERT into wp_product_instore ( post_id, meta_key, meta_value ) values ( $post_id, ‘post_title’, $title )” )); //likewise you … Read more