使用人工智能AI ChatGPT 开发了一个标签云页面的WordPress插件:Tag Cloud Page

最近一年来,美国的人工智能AI ChatGPT在社会各界引来了巨大的反响,人们纷纷为ChatGPT的超凡能力而感叹。我也从网上购买了ChatGPT 账户,让ChatGPT开发了一个标签云页面的WordPress插件:Tag Cloud Page。下面是具体代码。感觉ChatGPT可以胜任一些简单的wordpress开发了。我准备给ChatGPT作为本站的一个助理员工使用。

[box style=”info”]

/*

Plugin Name: Tag Cloud Page

Plugin URI:

Description: Generates a page displaying all tags used in the blog

Version: 1.0

Author:

Author URI:

*/

add_action(‘admin_menu’, ‘my_admin_menu’);

function my_admin_menu() {

add_menu_page(‘Tag Cloud Page’, ‘Tag Cloud Page’, ‘manage_options’, ‘tag-cloud-page/tag-cloud-page.php’, ‘my_admin_page’, ‘dashicons-admin-generic’, 6);

}

function my_admin_page() {

global $wpdb;

$terms = get_terms( array(

‘taxonomy’ => ‘post_tag’,

‘hide_empty’ => false,

) );

$tags = array();

foreach ($terms as $term) {

$tags[] = $term->name;

}

$total_count = array_count_values($tags);

echo ‘<h1>Tag Cloud Page</h1>’;

echo ‘<div class=”tag-cloud”>’;

foreach ($total_count as $tag => $count) {

$tag_link = get_tag_link( $tag );

$html = ‘<a href=”%1$s” class=”tag-cloud-link” style=”font-size: %2$s”>%3$s</a>’;

$html = sprintf( $html,

$tag_link,

( $count / max( $total_count ) ) * 10 + 1 . ‘px’,

$tag

);

echo $html;

}

echo ‘</div>’;

}

?–>

[/box]

 

 

 

 

分享至:

刘春晓

春晓网创始人和主编。2011年毕业于河南大学新闻与传播学院,计算机和互联网爱好者。

您可能还喜欢...