2024年10月17日 /** * 修改文件,就更新缓存 */ function my_load_scripts($hook) { // 把文件修改时间当做版本号 $my_css_ver = date("ymd-Gis", filemtime(get_template_directory() . '/style.css')); // 加载 style.css wp_enqueue_style('style-css', get_stylesheet_

2024年10月17日 实现方法一: <?php $category = get_the_category(); echo $category[0]->cat_name; ?> 实现方法二: <?php foreach((get_the_category()) as $category) { echo $category->cat_name; } ?>

2024年10月17日 如何利用get_calendar函数实现统计文章发布日历,下面web建站小编给大家简单介绍一下具体实现方法。 函数原型: get_calendar( bool $initial = true, bool $display = true ): void|string 参数说明: $initial,是否使用初始日历名称。 $display,直接显示,还是返回一个字符串。 函数源码: function get_calendar( $initial = true, $displa

2024年10月17日 所谓的同源指:域名、网络协议、端口号相同,三条有一条不同就会产生跨域。下面web建站小编给大家简单介绍一下如何完美解决前后端跨域请求问题!​ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.cors.CorsConfiguration;

2024年10月17日 第一步,在header.php或footer.php中引入如下代码: <script type="text/javascript"> /* <![CDATA[ */ var ajax_sign_object = <?php echo ajax_sign_object(); ?>; /* ]]> */ </script> 第二步,找到functions.php文件新增以下代码: /* 获取当前页面url /* -

2024年10月17日 找到当前主题函数模板functions.php中新增以下代码: function get_tag_post_count_by_id( $tag_id ) { $tag = get_term_by( 'id', $tag_id, 'post_tag' ); _make_cat_compat( $tag ); return $tag->count; } 调用代码: <?php echo get_tag_post_count_by_id( $t

2024年10月17日 函数介绍: comments_template( string $file = '/comments.php', bool $separate_comments = false ) 参数说明: $file:(字符串)(可选)要加载的文件,默认值:’/comments.php’; $separate_comments(布尔值)(可选)是否按评论类型划分评论,默认值:false。

2024年10月16日 在wordpress上的文章页面一般都会显示当前页面的阅读量,但是有的文章的阅读量比较少,如何在当前的阅读量上新增一个基数呢? 在内容页面搜索the_views();改成以下代码: //默认基数为500 echo (int)(500 + (int) get_post_meta( get_the_ID(), 'views', true )); //默认基数从500-999中随机生成 echo (int)(rand(500,999) + the_views(fals

2024年10月16日 wordpress建站中如何利用ajax直接删除文章(移到回收站中),下面web建站小编给大家简单介绍一下具体实现代码! 1、新建一个movepost.js​文件 jQuery(function($){ $('body.post-type-post .row-actions .trash a').click(function( event ){ event.preventDefault(); var url = new URL( $(th

2024年10月16日 wordpress建站如何某些邮箱后缀做限制,也就是说不允许部分后缀类型的邮箱注册!具体实现代码如下: 在functions.php中新增以下代码: //设置邮箱白名单 function is_valid_email_domain($login, $email, $errors ){ $valid_email_domains = array("gmail.com","qq.com");// 允许注册的邮箱信息 $valid = false; for

2024年10月16日 wordpress如何检测当前页面是否已被百度收录,下面web建站小编给大家简单介绍一下具体实现方法! 在functions.php中新增以下代码: function baiduSL($url){ $url='http://www.baidu.com/s?wd='.$url; $curl=curl_init(); curl_setopt($curl,CURLOPT_URL,$url); curl_setopt($curl,CURLOPT_RETUR

2024年10月16日 如何利用wordpress中的the_author()函数获取当前作者链接,下面web建站小编给大家简单介绍一下具体实现代码! 函数原型: the_author( string $deprecated = '', bool $deprecated_echo = true ): string|null 调用方法: the_author();

2024年10月16日 wordpress建站seo优化的时候会用到描述,下面web建站小编给大家简单介绍一下如何利用wordpress自带的term_description函数获取分类描述信息! 函数源码: function term_description( $term = 0, $deprecated = null ) { if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) { $term = g

2024年10月16日 以下是基础代码,根据自己需要进行修改! <?php $rand_posts = get_posts('numberposts=8&orderby=rand'); //循环随机显示文章数 foreach( $rand_posts as $post ) : ?> <dl> <?php $litpic = get_post_meta($post->ID, 'litpic', true); if (

2024年10月16日 wordpress建站如何在二级目录建站,只要两步就可以完成,下面web建站小编给大家简单介绍一下实现方法! 1、打开wp-config.php文件新增以下代码: if ( defined( 'WP_CLI' ) ) { $_SERVER['HTTP_HOST'] = '域名'; } define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/二级目录名'); define(

最新内容