WordPress给特色图片添加选项

有些主题的特色图像会显示在文章内页里面,多数情况下我们并不想让它显示在内页里,那么我们可以添加一个选项控制显示。代码如下: function prefix_featured_image_meta( $content ) { global $post; $text = __( ‘Don\’t display image in post.’, ‘prefix’ ); $id = ‘hide_featured_image’; $value

将以下php代码复制到当前主问题录下的functions.php中,即可让WordPress支持使用中文用户名注册和登录:

WordPress媒体文件加分类和标签

今天介绍的方法可以实现给多媒体添加独立的分类,而不必混用文章的分类,而且在WordPress后台的多媒体列表页可以直观显示媒体的分类。 使用方法,同样是在当前主题的functions.php中添加php代码: function mobantu_create_media_category() {   $args = array(     ‘label’ => ‘媒体分类’,     ‘hierarchical’ => tru

function mobantu_sanitize_user ($username, $raw_username, $strict) {
 $username = wp_strip_all_tags( $raw_username );
 $username = remove_accents( $username );
 // Kill octets
 $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
 $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities

 // 网上许多教程都是直接将$strict赋值false,
 // 这样会绕过字符串检查,留下隐患
 if ($strict) {
 $username = preg_replace ('|[^a-z\p{Han}0-9 _.\-@]|iu', '', $username);
 }

 $username = trim( $username );
 // Consolidate contiguous whitespace
 $username = preg_replace( '|\s+|', ' ', $username );

 return $username;
}

add_filter ('sanitize_user', 'mobantu_sanitize_user', 10, 3);

 

WordPress获取使用指定页面模板的页面id

什么是模板呢?默认情况 WordPress是使用主题目录下page.php来作为模板显示页面的,但是有时候我们需要不同的模板来显示页面,比如登录、注册和投稿页面等,这些页面跟普通的页面是有所区别,这时候WordPress提供了页面模板让开发者可以自定义WordPress页面外观甚至功能。 页面模板php文件的匹配 WordPress中是通过自定义栏目来记录页面所使用的模板的,自定义栏目名称:_wp_page_template,值为模板的

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。