It is possible to add extra button under the 'publish' button in the post of wordpress? and how?

Actually i need such a function , when we click on the "publish" button of the post in word press, after publish automatically go this page on the desired link()..

2nd :if we add a button "return link " just bellow the "publish" button ,then also i can get this function.. my question is how how to solve this problem and how we add button on the wordpress post under the publish button?

Topic buttons posts Wordpress

Category Web


Use this code to go to a newly published post-

function wpse248883_post_published_notification( $ID, $post ) { $permalink = get_permalink( $ID ); wp_safe_redirect( $permalink ); exit(); } add_action( 'publish_post', 'wpse248883_post_published_notification', 10, 2 );

And for a new button, use this-

add_action( 'post_submitbox_start', 'wpse248883_new_button' ); function wpse248883_new_button(){ ?> <div> <input name="save" type="button" class="button-large button-primary" value="New Button" /> </div> <?php } It'll add a button above Publish button.


Here is how you can add another button to the admin page.

Download the MetaBox plugin
Create a file called "button.php" in the wp-content folder
Inlcude "button.php" in functions.php
In button.php, type:

add_filter( 'rwmb_meta_boxes', 'admin_button_register_meta_boxes' );

function your_prefix_register_meta_boxes( $meta_boxes ) {

    $prefix = 'admin_button_';

    $meta_boxes[] = array(

        'id'         => 'standard',

        'title'      => esc_html__( 'Standard Fields', 'admin_button' ),

        'post_types' => array( 'post', 'page' ),

        'context'    => 'side',

        'priority'   => 'high',

        'autosave'   => true,
        // List of meta fields
        'fields'     => array(
             array(
                'id'   => 'custom_html',
                // Field name: usually not used
                // 'name' => __( 'Custom HTML', 'admin_button' ),
                'type' => 'custom_html',
                // HTML content
                'std'  => ' ',

            ),
           ),
      );

    return $meta_boxes;
}

Now you have a form controlled by the button. Depending on what you want to do with the button, you can have a PHP method check to see if the form was posted or you can have the button trigger a javascript event.

Hope that helps!

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.