Automatically add link to custom field using the WordPress “Press this” button

The title pretty much explains it , I have a client that would like to be able to surf the net, click the wordpress “press this” button and automatically have the page link added to a custom field. I know this is possible bc when you click the “press this” button it automatically adds the link from the page you were on into the post window as a href link .

A next best solution would be finding a way to edit the output to the editor to remove the extra text wordpress adds to the editor automatically.

Related posts

Leave a Reply

2 comments

  1. Its solution is to prepend or append a hidden field in form post form. In value you have to echo $_GET[‘u’]. Now, on submit through ajax, you will see that your hidden field is submitted with the URL.

    Here you can hook “save_post” and update custom field for that field name $_POST[‘field-name’].

    P.S. If you want me to paste the script too so please reply.

    Here is the working example for prepend:

    <?php function admin_footer_scripts(){?>
    <script type="text/javascript" language="javascript">
    
    jQuery(document).ready(function($){
        //$('#url-scan-submit').on('click', function(){
            $('#pressthis-form').prepend('<input type="hidden" name="link_url" value="<?php echo isset($_GET['u'])?$_GET['u']:''; ?>" />');
        //});
    });</script><?php   
    } 
    add_action('admin_footer', 'admin_footer_scripts');
    ?>
    
  2. I think what you are requesting is possible but you would probably need to reworke both the bookmarklet and use a custom plugin rather than the standard press-this.php. (I’ve not checked but there might be pressthis hooks as well.)

    I’ve also had great success with Gravity forms since it easily creates posts and can populate custom fields directly from URL parameters. A custom bookmarklet plus gravity forms would be a pretty effective solution for what you are describing.