0

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?

2 Answers 2

0

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!

0
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.