为WordPress文章图片自动添加链接到原图

为WordPress文章图片自动添加链接到原图是为了图片灯箱效果。灯箱效果需要链向自身的a标签,并且a标签里要有data-imgbox="imgbox"属性(其他灯箱实现方法可能不一样)。function方法有缺陷,只有图片本身没有a标签时可以使用。//wordpress图片自动添加链接 add_filter('the_content', 'fancybox1'); add_filter('the

- 阅读全文 -

WordPress给外链添加添加nofollow和新窗口打开属性

WordPress给外链添加添加nofollow和新窗口打开属性,可以设置白名单,白名单只添加target="_blank"。代码一:// 外链nofollow和target="_blank",支持白名单 add_filter('the_content', 'wl_the_content'); function wl_the_content($content) { //

- 阅读全文 -

禁止加载WordPress自带的jquery.js

//禁止加载WP自带的jquery.js if ( !is_admin() ) { // 后台不禁止 function my_init_method() { wp_deregister_script( 'jquery' ); // 取消原有的 jquery 定义 } add_action('init', 'my_init_method'); } wp_deregister_script( 'l

- 阅读全文 -

WordPress后台隐藏左上角WordPress标志

// 隐藏左上角WordPress标志 function hidden_admin_bar_remove() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); } add_action('wp_before_admin_bar_render', 'hidden_admin_bar_remove', 0

- 阅读全文 -

WordPress移除头部wp_json链接

//移除头部wp_json链接 remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );

- 阅读全文 -