Simple Create WordPress Plugin Tutorial

Today, We want to share with you Simple Create WordPress Plugin Tutorial.In this post we will show you Create a Live Demo of Your WordPress Plugin, hear for how to create plugin in wordpress step by step with example we will give you demo and example for implement.In this post, we will learn about How to Build WordPress Plugin – Example App and Live Demo with an example.

Simple Create WordPress Plugin Tutorial

There are the Following The simple About Simple Create WordPress Plugin Tutorial Full Information With Example and source code.

As I will cover this Post with live Working example to develop create wordpress plugin from scratch, so the create wordpress plugin with database for this example is following below.

Structure of the WordPress Plugin

| – readme.txt
| – auto-post-hook.php

Coding WordPress Plugin

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

auto-post-hook.php

<?php
/*
Plugin Name: Auto post hook.
Description: This plugin acts as a hook for auto post Web Service.
Author: Jd Angularjs KING
Author URI: https://www.pakainfo.com/about
Version: 1.0.1
*/
function autopost_retrieve_random_post() {
  $autopostArguement = array('posts_per_page' => 1,'orderby' => 'rand');
  $autopostRandomPost = get_posts($autopostArguement);
  if (empty($autopostRandomPost)) {
        return null;
  }
  $autopostPost = $autopostRandomPost[0];
  $autopostPost->permalink = get_permalink($autopostPost->ID);
  $autopostPost->hash_tags = wp_get_post_tags($autopostPost->ID,array( 'fields' => 'names' ));
  return $autopostPost;
}
add_action('rest_api_init', function(){
        register_rest_route( 'autopost/v1', '/posts/', array(
                'methods' => 'GET',
                'callback' => 'autopost_retrieve_random_post',
        ));
});
?>

Running our WordPress AutoPOST Plugin

http://your_domain_name.com/jdk_wp/index.php/wp-json/autopost/v1/posts

Web Programming Tutorials Example with Demo

Read :

Another must read:  Wordpress Plugin uninstall hook - register_uninstall_hook()

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Create Word-Press Plugin Tutorial.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

Your email address will not be published. Required fields are marked *