Tuesday, September 22, 2020
Wordpress Cheat Codes

WordPress Cheat Code to add Post from Frontend

How to add custom meta title and meta description in Wordpress?

Hello to all, welcome to therichpost.com. In this post, I will tell you, WordPress Cheat Code to add Post from Frontend.

Today, I am going to start new topic named WordPress Cheat Code
and in this topic, I will share all WordPress Cheat Code, which will help others to make wordpress code easy.
Today, I will write first post for this topic name WordPress Cheat Code to add Post from Frontend.

WordPress plays very important role in website world and I personally like WordPress very much. There are many WordPress developers in the world and I am one of the best WordPress developer(hahaha).

WordPress developers, today I am going to make your life easy with my today post.

In this post, I am just adding the title from frontend post form and In future posts, I will add post featured image and other things.

Here is the code for WordPress Cheat Code to add Post from Frontend and you can add this into any your wordpress theme’s template file.

if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {
$new_post = array(
        'post_title'    =>  $_POST['title'],
        'post_status'   => 'publish', // Choose: publish, preview, future, draft, etc.
        'post_type'     => 'post' //'post',page' or use a custom post type if you want to
  <div class="row">
     <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
           <div class="card-header">
              <h2 class="card-title">Add POST</h2>
                <div class="card-body">
                   <div class="row">
                       <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                           <form id="new_post" name="new_post" method="post" action="">
                              <div class="form-group">
                                    <label>POST Title</label>
                                    <input type='text' class="form-control" required="" name="title" />
                                <div class="row">
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                                        <div class="form-group">
                                            <input type="submit" value="Save" class="btn btn-custom login-btn pull-right"/>
                                <input type="hidden" name="action" value="new_post" />
                <?php wp_nonce_field( 'new-post' ); ?>


This is it and if you have any query related to this post then please do comment below.


Thank you.

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10 Nodejs, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.