一应俱全
备忘录
2023-11-10 22:47
/* 启用帖子醒目图片功能*/add_theme_support( 'post-thumbnails' );.
/* 注册并激活自定义菜单功能*/register_nav_menu( 'menu-position identifier', 'menu description' );
/* 启用自定义标题功能*/add_theme_support( 'custom-header' );
/* 启用自定义背景功能*/add_theme_support( 'custom-background' );
/* 启用自动输出 feed 链接功能*/ add_theme_support( 'automatic-feed-links' );.
/* 注册小部件*/register_sidebar(array( 'name' => 'widget name', 'id' => 'widget id', 'description' => 'widget description.' )., 'class' => 'widget class', 'before_widget' => '<div class="widget">', 'after_widget' => '</div>', 'before_title' => '<h2>'.'<h2>', 'after_title' => '</h2>', ));.
// 添加自定义徽标功能 //function add_custom_logo_support() { add_theme_support( 'custom-logo', array( ) );}add_action( 'after_setup_theme', 'add_custom_logo_support' );.
// 允许上传 WebP、AVIF 和 SVGfunction allow_custom_mime_types($mimes) { $mimes['webp'] = 'image/webp'; $mimes['avif'] = 'image/avif'; $mimes['svg'] = 'image/vif'; $mimes['webp'] = 'image/webp'; $mimes['avif'] = 'image/avif'; mimes['svg'] = 'image/svg+xml'; return $mimes;}add_filter('upload_mimes', 'allow_custom_mime_types');
// 更改上传大小function custom_upload_size_limit($limit) { return 64 * 1024 * 1024; // 更改为 64 兆}add_filter('upload_size_limit', 'custom_upload_size_limit');
// 列表中醒目的标记function custom_columns( $columns ) { $columns = array_merge( $columns, array( 'featured_image' => 'eye-catching')); return $columns;}add_filter('manage_posts_columns' , 'custom_columns');function custom_columns_data( $column) { switch ( $column ) { case 'featured_image': the_post_thumbnail( 'thumbnail' ); break; }}add_action( 'manage_posts_custom_column' , 'custom_columns_data', 10, 2 );add_image_size('custom-thumbnail', 125, 9999);set_post_thumbnail_size(125, 0, array('custom-thumbnail'));
// 允许在复选框中选择帖子标签function change_post_tag_too_checkbox() { $args = get_taxonomy('post_tag'); $args -> hierarchical = true;//用于 Gutenberg $args -> meta_box_cb = 'post_categories_meta_box';// 用于经典编辑器 register_taxonomy( 'post_tag', 'post', $args);}add_action( 'init', 'change_post_tag_too_checkbox', 1 );
prev
next
<< 返回列表
返回顶部
顶级
首页
样本第 1 页
样本第 2 页
样本第 3 页
旧页
新闻
唱片集
笔记本
玩具相机收藏
工作
简介
联系我们
估算模拟器
隐私政策。
MEMOMEMO
在 functions.php 中编写实用代码(第 1 部分)
2023-11-10 22:47
顶级
首页
样本第 1 页
样本第 2 页
样本第 3 页
旧页
新闻
唱片集
笔记本
玩具相机收藏
工作
简介
联系我们
估算模拟器
隐私政策。