Outputting query results
By default, wordpress get_results return a numerically array of objects, so to use echo to print your data yo should do something like; foreach($myrows as $line){ echo $line->question; }
By default, wordpress get_results return a numerically array of objects, so to use echo to print your data yo should do something like; foreach($myrows as $line){ echo $line->question; }
Normally WordPress does not allow you to delete ‘super admin’ through its dashboard, all other users can be deleted. But in your case I think, its some one who deleted all users from the table directly by accessing your WordPress database via phpmyadmin or so. Even if there is no users in the site, the … Read more
WordPress already has both user and post meta data tables, and associated API for handling the data. Storing an array of post IDs for each user in user meta sounds like it would work for your application.
Bulk of WP’s native data structures aren’t meant for direct MySQL access. They are typically accessed via PHP APIs which take care of MySQL generation/execution and many more things, such as allowing to filter data, caching it for performance, and so on. Your issue here is that from MySQL point of view meta values aren’t … Read more
I have updated the URLs stored in the database when the domain has changed. Here are the things to watch for: In the posts table, the post_content will have any embedded links. These you can change without issue. Again in the posts table, the gid would change if you do a global search and replace. … Read more
It seems you issue is with the below code piece: if ( $results ) { foreach ( $results as $result ){ echo $result[0]; } } echo $result[0]; should just be echo $result;. $results is your array so to use $results[0] (note the s) you would need a for loop and not a foreach loop. if … Read more
You probably don’t need a custom table. Read the top answer to this question which recommends using Custom Post Types. As for displaying the data, I’d recommend you investigate Custom Page Templates. Then you can create a page that loads your data however you’d like.
Use stripslashes to remove the slashes. For example: echo stripslashes( $field );
You’re including the table prefix, but $wpdb takes care of that. Change: $query = $wpdb->prepare( “SELECT * FROM $wpdb->wp_terms INNER JOIN $wpdb->wp_term_taxonomy ON ($wpdb->wp_terms.term_id = $wpdb->wp_term_taxonomy.term_id) WHERE $wpdb->wp_terms.name LIKE %s AND $wpdb->wp_terms.count > 0”, $wpdb->esc_like($keyword) . ‘%’); To: $query = $wpdb->prepare( “SELECT * FROM $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) WHERE $wpdb->terms.name LIKE … Read more
The way that I backup our site is two-fold. Via our web host (rackspace) and manually every time I write any code for the site. DISCLAIMER: this is just what I do by habit, I don’t claim it’s the best or only way to do it. Just sharing. Firstly your provider may have an automated … Read more