Create a new column for posts with a short link wp_get_shortlink
To create a short link in a separate column of the list of articles, just paste the code in the file functions.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
add_filter( 'manage_posts_columns', 'shortlink_add_column' ); add_action( 'manage_posts_custom_column', 'shortlink_add_value', 10, 2 ); function shortlink_add_column($cols) { $cols['shortlink'] = __('Shortlink'); return $cols; } function shortlink_add_value($column_name, $post_id) { if ( 'shortlink' == $column_name ) { echo '<input type="text" value="'.wp_get_shortlink($post_id).'" onclick="this.focus(); this.select();" />'; } } add_filter( 'manage_edit-post_sortable_columns', 'shortlink_sortable_column' ); function shortlink_sortable_column( $columns ) { $columns['shortlink'] = 'Shortlink'; return $columns; } |
An example of what happens
Now you can just copy a short link to post it on twitter or other social networks. Try and test on your test sites, I checked everything and everything works. Good luck with development.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.
Good afternoon
Is it possible to display here under the title of the article the full news?
I think it's possible, I haven't tried this yet. I think, which then will not be convenient to work with a large number of articles.
Usually if you need to find and edit an article on the site, it will be easier to find it in the search and click the edit button in the admin bay.
maybe, I didn't understand the problem. Describe the problem, which you want to solve and I will try to offer a solution to the problem.
Jokes from other sites are robbed on my site and hang in approval mode. It's a little expensive to go in and look into each.
Now, if it immediately showed, then I would immediately remove the inappropriate ones.
Thanks
Found a solution to your problem. Described in a new lesson.
http://wp-admin.com.ua/ekshenyi-i-skriptyi-dlya-wordpress/
The solution turned out to be simple, I think it will be what you need.
Solution described last.