Is it possible to utilize custom SQL for a single-post.php?

If you just want the ID of the requested post within the template, get_queried_object_id() will give you that. If you want to modify the main query SQL before it’s executed, there are a number of filters that let you directly modify the SQL.

query sql-table and change entities

You should gotten return from SQL first. And then print results. Use $wpdb class for SQL queries. If you wanna use native SQL queries something like this might helps you $result = mysql_query(“SELECT * FROM table”); $result_array = mysql_fetch_array($result, MYSQL_ASSOC); But it`s very bad idea. Use $wpdb with preparing.

How do I display SQL query on a specific page of my wordpress site

$result = $wpdb->get_results( “SELECT `account_number`,`consumer_name`,`bill_amount`,`due_date`,`disco_date`,`bill_status` FROM {$wpdb->prefix}_bill_inquiry where `account_number` = ‘$inputnumber’ AND `pin_number` = ‘$inputpin'”, OBJECT ); $wpdb->prefix will automatically print the prefix, then to convert the result in array form you can use the following snippet: $result = json_decode(json_encode($result),true); You can either place it in a template or you can create a shortcode in … Read more

How to Add or Change Post Title

The first thing you want to do will be find the post you want to modify. To find the post named “beddu” which post_type is post, you can excute this query: SELECT * FROM wp_posts WHERE post_type=”post” AND post_title=”beddu”; After you test and find the condition is correct. Move to update part. UPDATE wp_posts SET … Read more

Fastest way to display 5000 post titles?

In my opinion and from what i’ve seen on testing. Using any WordPress function will slow things down dramatically. The fastest way i found to do this is by querying MySQL directly and grabbing only the things needed. For example: $products = $wpdb->get_results( “SELECT post_title, post_name FROM `wp_posts` WHERE post_type=”products””, ARRAY_A ); echo ‘<ol>’; foreach … Read more