How to Create a WordPress Plugin Part1

By | 23rd July 2017
How to Create a WordPress Plugin Part1

In this introduction to creating a WP plugin we will create a simple WordPress plugin. I will demonstrate the following concepts in this video tutorial:

– creating administration pages
– using the wordpress styles to create your admin styling
– interacting with the WP database using the $ wpdb object

Tutorial Part 2 – http://www.youtube.com/watch?v=zmMbaWz-hvI
Full Blog Post – http://www.tipsandtricks-hq.com/how-to-create-a-wordpress-plugin-video-tutorial-4547

20 thoughts on “How to Create a WordPress Plugin Part1

  1. Martin Kaspar

    – wow – a very usefu. tutorial – one question left: can you add some written down material – on your website or some where… that would fit very very well. love to hear from you – greetings martin

    Reply
  2. Martin Kaspar

    overwhelming – this tutorial is very very helpful – thanks for sharing this with us

    Reply
  3. Ankit Sharma

    how to add css and js files to the plugin without conflict with wordpress rest js/css files.

    Reply
  4. Lautaro Parada

    In case that you need, thank me later.

    <?php
    /*
    Plugin Name: myfirstplugin
    Plugin URI: http://www.example.com
    Description: mi primer plugin
    Version: 1.0
    Author: Pikachu
    Author URI: http://www.example.com
    License: GLP2
    */
    add_action('admin_menu','myfirstplugin_admin_actions');
    function myfirstplugin_admin_actions(){
    add_options_page('MyFirstPlugin','MyFirstPlugin','manage_options',__FILE__,'myfirstplugin_admin');
    }

    function myfirstplugin_admin()
    {
    ?>
    <div class="wrap"> <!-estudiar la clases en CSS->
    <h4>A more intereting Hello World Plugin</h4>
    <table class="widefat">
    <thead>
    <tr>
    <th> Post title</th>
    <th> Post ID </th>
    </tr>
    </thead>
    <tfoot>
    <tr>
    <th> Post title</th>
    <th> Post ID </th>
    </tr>
    </tfoot>
    <tbody>
    <?php
    global $wpdb;

    $mytestdrafts = $wpdb->get_results(
    "
    SELECT ID, post_title
    FROM $wpdb->posts
    WHERE post_status = 'draft'
    "
    );
    ?>
    <?php
    foreach ($mytestdrafts as $mytestdraft){
    ?>
    <tr>
    <?php
    echo"<td>".$mytestdraft->post_title."</td>";
    echo"<td>".$mytestdraft->ID."</td>";
    ?>
    </tr>

    <?php
    }
    ?>
    </tbody>
    </div>
    <?php
    }
    ?>

    Reply
  5. Alina ZemlienÄ—

    Excellent tutorial! It is exactly what I needed! Helped me a lot. Now it's much more clear for me about MySQL, PHP, HTML interactions within WordPress. Thank you very much!

    Reply
  6. 600 Ways

    Also more relevant class to use in your table ( As of WordPress v4.4.2 ) is "wp-list-table widefat fixed striped" – This will add the alternating rows and improve column spacing

    Reply
  7. 600 Ways

    How do I only display actual Article Posts, and not All posts, like Media posts etc etc? — Gamingdonks is right, you are missing a table tag at 6:40

    Reply
  8. Mansouri Najeh njh

    thx for the tutorial, but the problem is, the settings menu dosen't show the plugin i'm working with.

    Reply
  9. wawa wawar

    very evry comprehensive, very good Tutorial. Thanks a lot

    Reply
  10. Daryl H

    I got a tip for you…. Try showing us the full code before you upload…

    Reply
  11. Inkoopstunter.nl

    Hi there, It seems to me that I don't have any drafts showing.
    Should I put them in mysql myself?

    Reply

Leave a Reply