为WordPress文章图片自动添加链接到原图
为WordPress文章图片自动添加链接到原图是为了图片灯箱效果。灯箱效果需要链向自身的a标签,并且a标签里要有data-imgbox="imgbox"属性(其他灯箱实现方法可能不一样)。function方法有缺陷,只有图片本身没有a标签时可以使用。//wordpress图片自动添加链接 add_filter('the_content', 'fancybox1'); add_filter('the
为WordPress文章图片自动添加链接到原图是为了图片灯箱效果。灯箱效果需要链向自身的a标签,并且a标签里要有data-imgbox="imgbox"属性(其他灯箱实现方法可能不一样)。function方法有缺陷,只有图片本身没有a标签时可以使用。//wordpress图片自动添加链接 add_filter('the_content', 'fancybox1'); add_filter('the
//禁止WordPress头部加载s.w.org add_filter( 'emoji_svg_url', '__return_false' );
//WordPress 5.0+移除 block-library CSS remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
请输入密码访问
WordPress给外链添加添加nofollow和新窗口打开属性,可以设置白名单,白名单只添加target="_blank"。代码一:// 外链nofollow和target="_blank",支持白名单 add_filter('the_content', 'wl_the_content'); function wl_the_content($content) { //
//禁止加载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的文章嵌入功能 function disable_embeds_code_init() { // Remove the REST API endpoint. remove_action( 'rest_api_init', 'wp_oembed_register_route' ); // Turn off oEmbed auto discovery.
//去掉顶部工具栏 add_filter('show_admin_bar', '__return_false');相关阅读:https://boke112.com/bkwd/4093.html
// 隐藏左上角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
//移除头部wp_json链接 remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );