First of all I am new with WordPress and PHP. I want a reward module where I can have multiple categories and for each category multiple winners.
I have achieved that in CI (CodeIgniter) but now wanted to implement the similar stuff in WordPress. Where I can Have one category and that category can have multiple winners with there respective position.And I will be able to perform simple crud functionality.
Any suggestion how can be this model can be implemented in WordPress or if there any plugin is available with somewhat similar functionality?
Should I create my own plugin for this and for the start I have tried this
$your_db_name = $wpdb->prefix . 'your_db_name';
// function to create the DB / Options / Defaults
function your_plugin_options_install() {
global $wpdb;
global $your_db_name;
// create the ECPT metabox database table
if($wpdb->get_var("show tables like '$your_db_name'") != $your_db_name)
{
$sql = "CREATE TABLE " . $your_db_name . " (
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`field_1` mediumtext NOT NULL,
`field_2` tinytext NOT NULL,
`field_3` tinytext NOT NULL,
`field_4` tinytext NOT NULL,
UNIQUE KEY id (id)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
}
// run the install scripts upon plugin activation
register_activation_hook(__FILE__,'your_plugin_options_install');
Any suggestions? Thanks in advance
There’s no need to create a custom database table to do this.
WP_Query
capabilities and create regular theme templates, or widgets, or shortcodes, to output results.There are good plugins to manage CPTs and Custom Fields that make this easy, but here’s the small plugin outlined above: