Why Query is returning empty array?
you may need to wrap $slug in quotes $course = $wpdb->get_results( “SELECT * FROM wp_posts where post_name=”$slug”” );
you may need to wrap $slug in quotes $course = $wpdb->get_results( “SELECT * FROM wp_posts where post_name=”$slug”” );
SELECT * FROM wp_posts, wp_2_posts, wp_3_posts WHERE wp_posts.post_content LIKE ‘%foo’ OR wp_2_posts.post_content LIKE ‘%foo’ OR wp_3_posts.post_content LIKE ‘%foo’; should do the trick. (Note that in Multisite, there shouldn’t be a wp_1_posts — your root site uses wp_posts etc.)
Here is what is happening with your code: query_posts uses the global variable wp_query. It always overwrites that variable, which is why you should not use query_posts pretty much ever. Your first query_posts clobbers the original $wp_query data. You start the Loop The first thing you do in that loop is reset $wp_query to the … Read more
This is actually not that hard, but you will have to excuse me for keeping it high level because this is just a stupid thing to do as all things which are security by obscurity. All you need to do is write your WPDB driver, which inherits the WPDB class. Place it in /wp-content/db.php file … Read more
Are you sure that’s the table name? Usually on install WordPress prompts you to setup a table prefix so the default isn’t wp_. Additionally, you need to call the global $wpdb object so it’s accessible to use: global $wpdb; $user_count = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->users” ); echo “<p>User count is {$user_count}</p>”; Finally, to prevent … Read more
It’s not displayed as table, because you don’t return correct HTML code. Let’s take a look at your code (I’ve put comments at end of incorrect lines): $content=”<table>”; $content .= ‘</tr><th>Week Beginning</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th><th>Weekly Total</th><th>Previous Week Totals</th></tr>’; // <- here you open TR with </tr>, so it’s already incorrect $results = $seconddb->get_results( ‘ SELECT * FROM seconddb_PontoonBoats_LineOne_2Log’ … Read more
There is error in sql query. You have defined time as datetime and default value mentioned in current_timestamp. Define time as timestamp. Also specify length of email and page fields. Corrected query: $sql = “CREATE TABLE ” . $table_name . ” ( id INT NOT NULL AUTO_INCREMENT, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, //Change datetime … Read more
When I started out with WordPress I was anti-plugin. I wanted to add everything in my theme’s functions.php. When I looked at the bigger picture it began making sense having and leaving some functionalities inside a plugin. There are many write-ups on the subject of what should go into a plugin and what should go … Read more
Since my theme did not recognize wp block table class I have added table Sass class from Gutenberg to my theme. .wp-block-table { width: 100%; min-width: 240px; border-collapse: collapse; margin-bottom: 24px; td, th { padding: .3em; border: 1px solid rgba(0, 0, 0, 0.1); word-break: break-all; } th { text-align: center; } }
Custom table naming/access convention for multisite: $table_prefix vs base_prefix or other?