• W*W Logged in
  • a***n Logged in
Categories
  • Categories
  • Christmas
  • 初创
  • Courses

WordPress 自定义分类、标签、页面的URL伪静态格式,加.html后缀: function custom_page_rules() { global $wp_rewrite; /** page页面自定义URL样式 **/ $wp_rewrite->page_structure = $wp_rewrite->root . ‘page/%pagename%.html’; /** tag页面自定义URL样式 **/ $wp_rewrite->extra_permastructs[‘post_tag’][‘with_front’] = ”; $wp_rewrite->extra_permastructs[‘post_tag’][‘struct’] = $wp_rewrite->extra_permastructs[‘post_tag’][‘with_front’] . ‘tag/%post_tag%.html’; /** category页面自定义URL样式 **/ $wp_rewrite->extra_permastructs[‘category’][‘with_front’] = ‘category’; $wp_rewrite -> extra_permastructs[‘category’][‘struct’] = $wp_rewrite->extra_permastructs[‘category’][‘with_front’].’/%category%.html’; } add_action( ‘init’, ‘custom_page_rules’ ); 修改后需要重新保存下固定链接的规则。
2020-03-14 4.72k 0

将以下php代码复制到当前主题目录下的functions.php中,即可让WordPress支持使用中文用户名注册和登录: function MBT_sanitize_user ($username, $raw_username, $strict) { $username = wp_strip_all_tags( $raw_username ); $username = remove_accents( $username ); $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); $username = preg_replace( '/&.+?;/', '', $username );  if ($strict) { $username = preg_replace ('|[^a-z\p{Han}0-9 _.\-@]|iu', '', $username); } $username = trim( $username ); $username = preg_replace( '|\s+|', ' ', $username ); return $username; } add_filter ('sanitize_user', 'MBT_sanitize_user', 10, 3);
2018-12-07 4.21k 0

WordPress 后台编辑器上传视频的时候是以video短代码返回到内容里的,这样子有些小程序没法识别,所以需要把短代码改成video标签。将以下代码加入到主题的functions.php里: remove_shortcode( 'video', 'wp_video_shortcode' ); add_shortcode( 'video', 'MBT_video_shortcode' ); function MBT_video_shortcode( $attr, $content = '' ) { global $content_width; $post_id = get_post() ? get_the_ID() : 0; static $instance = 0; $instance++; $override = apply_filters( 'wp_video_shortcode_override', '', $attr, $content, $instance ); if ( '' !== $override ) { return $override; } $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array( 'src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360, //'class' => 'wp-video-shortcode', ); foreach ( $default_types as $type ) { $defaults_atts[$type] = ''; } $atts = shortcode_atts( $defaults_atts, $attr, 'video' ); if ( is_admin() ) { if ( $atts['width'] > $defaults_atts['width'] ) { $atts['height'] = round( ( $atts['height'] * $defaults_atts['width'] ) / $atts['width'] ); $atts['width'] = $defaults_atts['width']; } } else { if ( ! empty( $content_width ) && $atts['width'] > $content_width ) { $atts['height'] = round( ( $atts['height'] * $content_width ) / $atts['width'] ); $atts['width'] = $content_width; } } $is_vimeo = $is_youtube = false; $yt_pattern = '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#'; $vimeo_pattern = '#^https?://(.+\.)?vimeo\.com/.*#'; $primary = false; if ( ! empty( $atts['src']...
2018-12-07 4.57k 0

1、将从模板兔购买的主题下载包解压,上传里面的主题文件modown.zip,然后将里面的oauth文件夹放至网站根目录(与wp-content、wp-admin同级),即类似 www.t.com/oauth/ 路径存在。 2、启用主题后,可以设置下菜单(外观 - 菜单)、小工具(外观 - 小工具) 3、若需要将首页设置成与演示站一样,看下面: 本教程比较粗略,需要使用者有一定的wordpress后台操作使用基础,后续详细的教程我们会相继放出,谢谢理解。
2018-12-07 7.53k 0

如果你需要在后台某个页面添加上传按钮,你需要用到wp_enqueue_media()这个函数,用于引入上传所需组件。 add_action ( 'admin_enqueue_scripts', function () { if (is_admin ()) wp_enqueue_media (); } ); html代码例如: <p> <input type="number" value="" class="regular-text process_custom_images" id="process_custom_images" name="" max="" min="1" step="1"> <button class="set_custom_images button">Set Image ID</button> </p> js代码例如: jQuery(document).ready(function() { var $ = jQuery; if ($('.set_custom_images').length > 0) { if ( typeof wp !== 'undefined' && wp.media && wp.media.editor) { $(document).on('click', '.set_custom_images', function(e) { e.preventDefault(); var button = $(this); var id = button.prev(); wp.media.editor.send.attachment = function(props, attachment) { id.val(attachment.url); }; wp.media.editor.open(button); return false; }); } } });
2018-12-07 3.05k 0
分类页可无限自定义分类法筛选

站点提示

WAW (witsarewalth. com) is pleased to launch a Christmas themed material, and we look forward to your selection and download of a massive collection of Christmas materials!Click to view details