Your easiest route to this is probably shortcodes, which effectively allow you to insert the output from a bit of PHP code in a post or page.
For example, this would create the shortcode [countpeople]
which you could pop in any post and it would render the value from the SQL statement using a $wpdb
helper function:
function my_plugin_name_count_people() {
global $wpdb;
return $wpdb->get_var("SELECT COUNT(*) FROM PEOPLE;");
}
add_shortcode('countpeople', 'my_plugin_name_count_people');
Read more about shortcodes here: https://codex.wordpress.org/Shortcode_API
Related Posts:
- Creating 20,000 Posts or Pages using a .csv file?
- How do I run SQL queries on a WordPress web page? [closed]
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- Speeding SQL queries for a large database?
- JOIN and SUM different statement results (Mailster Database)
- Memcaching recurring SQL Queries
- How to get database connection details without longing to cpanel in WordPress?
- Performing CRUD operations on front end in wordpress
- Get all the related data from WordPress DB
- What are the common security flaws I need to look for? [closed]
- Making my plugin multi-site compatible
- How to properly insert data into custom table via plugin
- How does WordPress handle MySQL row lock errors?
- Searching users with WP_List_Table plugin
- Convert WordPress posts to products in WooCommerce
- Can I explicitly specify ENGINE=InnoDB in WordPress?
- How can I list only sites that use a particular theme or plugin?
- Help!! I Screwed up my WP
- $wpdb->get_results() does not fetch results with unicode ‘WHERE’ clause
- Changing BIGINT to INT
- How can I get a list of plugins and which blogs are using them?
- Can I run multiple queries with $wpdb->prepare?
- How to remove duplicate Custom Fields?
- wordpress in nginx docker container connected to php:8-fpm container and mariadb container isn’t creating any tables on plugin activation
- greatest() function returns undefined property
- How to write one comment and publish on every post using database or plugin?
- How to get number of Affected rows from wordpress dbDelta() function
- How to determine what is generating large amount of database queries?
- Get post by ASC from custome field DATE picker
- Retrieving a Value from a wp-database
- MySql database help for a plugin
- How to remove Database Table in WordPress via Function file?
- mysqli_error() expects parameter 1 to be mysqli, null given in own db class
- Display data on Word Press site posts and pages from mysql table
- Help With MySQL to WPDB Query Conversion
- Problem with creating tables for Plugin
- get current date + 90 days and checking every day
- join 2 table orders wordpress plugin
- WordPress WPforms customization
- How can I perform high-level database merging for WordPress within continues delivery?
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- Plugin: register_deactivation_hook works perfectly well, while register_activation_hook suddenly stopped working
- Enabling WP_USE_EXT_MYSQL to support old plugin
- how to access all user dashboard on fronted page [closed]
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- WordPress Backend HA (Automatic failover)
- SQL to order by CPT results by user->display_name w/only user->ID known
- Enabling plugin failed because MySQL user do not have CREATE permissions
- Multiple instance of data in plugin custom database table on plugin activation
- Better ads plugin has 500.000 entries in wp_postmeta
- How to create multiple database tables on plugin activation?
- Does deleting a Plugin via the WordPress admin ‘completely’ remove the code?
- pagination on data fetched using SQL query
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- Cannot get wpdb data (Error in a simple fuction) [closed]
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- correct validate and sql query
- Using ‘mysqli_connect’ ‘crashes’ WordPress client-side
- Always get creating a new table with foreign key
- problem with sql query
- DB Query not working in Plugin
- Deactivation Hook does not remove database
- Way to send multiple values for column to MySQL?
- Comment Approve – Add custom function when comment is approved
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Can’t create tables with my plugin
- Using AJAX to run SQL statement and populate dropdown
- Check against server time to display SQL entries – Radio Station DJ Rotator Plugin
- Adding CASE in WP_Query
- WordPress Cache delete on plugin uninstall
- need to find duplicated meta value in custom filed and view the posts that have the same value
- How to get specific column data conditionally in database in WordPress?
- My CPU usage in A2 Hosting Shared Plan (Turbo Boost) is high due to mysql query!
- Getting current user data with MySQL statement
- What database state changes happen after a post is manually “updated” with no changes?
- WP Function does not trigger on Webhook API Call
- add products to WordPress site automatically
- Cant create table on plugin activation
- Looping the data from WordPress database using foreach
- WordPress UPDATE queries on MySQL database stuck
- Store GravityForm data in phpmyadmin (mysql)
- Moving a few select DB tables to a new WP instance
- dbDelta not CREATING TABLE
- How To Toggle User_Meta in frontend in a form using PHP
- Get and Update Most Meta Value as an array in HTML form
- Login issue in WordPress
- WordPress filter from custom table is not working properly
- Delete user meta based on key value that is an array
- get/show Last ID
- Resetting AUTO_INCREMENT primary key
- correct validate inputs
- how to search through plugin in wordpress cimy-user-extra-fields?
- How to display blog posts only authored by the administrator
- Trying to insert a row from a Plugin
- how to show the data from a myqsl database in a post [closed]
- Post sorting and ordering function in WordPress Admin is broken and always shows post from oldest to newest
- PHP Creating a formula from mysql db values and db stored math operator
- How to change and edit users according to the extension in the URL
- Getting 504 Gateway Timeout Error on AWS Server! [closed]
- WordPress issue – data is not showing in wp-admin, but when searching through database, all the data is there