Press this, grab the $url and put into custom field
-
Hello,
So I was looking at how the Press This snippet works. It uses javascript to add the url to the post url, and then a GET function to retrieve it. Here is what the press-this.php does on line 119:
$url = clean_url($_GET['u']);
And here is what a link looks like:
...wp-admin/press-this.php?u=http%3A%2F%2Fwordpress.org%2F&t=WordPress%20%E2%80%BA%20Blog%20Tool%20and%20Publishing%20Platform&s=&v=2
I’d like to grab $url and apply it to a custom field value. I thought it would look something like this:
function ptlink() { global $url; global $wp_query; $thePostID = $wp_query->post->ID; add_post_meta($thePostID, 'test', $url); } add_filter('publish_post', 'ptlink');
But it doesn’t seem to work. Any suggestions, help? I am still learning php, my apologize.
- The topic ‘Press this, grab the $url and put into custom field’ is closed to new replies.