How to obtain a reference to $table_prefix in $wpdb object
global $wpdb; $prefix = $wpdb->prefix;
global $wpdb; $prefix = $wpdb->prefix;
When enhancing WordPress functionality, always use the theme’s functions.php file (located, generally, in {WP root}/wp-content/themes/{your theme}/functions.php), or put your code into a plugin. The rules for hacking core code are similar to the rules for optimization. Don’t do it. (for experts only) Don’t do it yet.
WordPress 3.4+ Method: Just define this define( ‘SHORTINIT’, true ); before you call wp-load.php
Here’s one thing you could do. Create a WP_Query object but only include ids: $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘books’, ‘s’ => $s, ‘fields’ => ‘ids’, ); $query = new WP_Query( $args ); $post_counts = $query->post_count; wp_reset_postdata(); By using fields => ids you’re only returning the IDs. Also, WP_Query already does a … Read more
I think the problem might lie in: $wpdbinfo = $wpdb->get_results(“SELECT * FROM bo_mytable WHERE id=3”); $wpdb->get_results() returns an array of objects, yet you are referencing a property on $wpdbinfo (->nameinfo). You’ll either want to loop through the $wpdbinfo array, or if you’re certain you’ll get only a single record (possibly a safe assumption if id … Read more
If you change the DB structure than you are effectively not running wordpress any longer, but your fork of it. This is not always a negative thing to do as long as you are aware that once you do it there is no guaranty that any plugin or theme or future wordpress version will work … Read more
I sort of fixed your query. It needs a table and a WHERE condition to prevent changing all rows. Even a LIMIT 1 at the end won’t hurt. $rows_affected = $wpdb->query( $wpdb->prepare( “UPDATE {$table} SET removed = %s, post_id = %d, user_id = %d, status = %d;”, $cur_date = date(‘Y-m-d H:i:s’), $postid, $userid, 0 ) … Read more
I have been searching for an answer to this question for over a month now – i do not think wordpress is very good for any site that has a secure external DB or for anyone who does not want to store customer data in the main wordpress database, which is strange as that seems … Read more
Here is my answer in code form: <?php // Customer Details $args = array( ‘blog_id’ => $GLOBALS[‘blog_id’], ‘role’ => ‘customer’, ‘meta_key’ => ‘last_name’, ‘meta_value’ => ”, ‘meta_compare’ => ”, ‘meta_query’ => array(), ‘date_query’ => array(), ‘include’ => array(), ‘exclude’ => array(), ‘orderby’ => ‘last_name’, ‘order’ => ‘ASC’, ‘offset’ => ”, ‘search’ => ”, ‘number’ => … Read more
Okay, new solution. First off, I’d recommend making the link a submit button and making the name something unique: <submit name ‘del_gallery’ /> Then in the code of your admin page: include ‘ga-functions.php’; //checks to see if certain button was pressed if(isset($_REQUEST[‘del_gallery’] && isset($_GET[‘gallery_id’]) ) { $gallery_id = $_GET[‘gallery_id’]; delete_gallery($gallery_id); wp_redirect( $_SERVER[‘HTTP_REFERER’] ); exit(); }