2024年10月14日 功能介绍:利用wordpress建站,如何直接在数据库中利用mysql语法批量插入文章,下面给大家简单介绍一下具体插入语法! 具体代码如下: INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`

2024年10月14日 功能介绍:把Tag标签当做keywords来使用,但是如果直接调用the_tags()方法会出现超链接问题,所有需要重新定义一个方法! 找到主题下functions.php文件,新增一下代码: function tagtext(){ global $post; $gettags = get_the_tags($post->ID); if ($gettags) { foreach ($gettags as $tag) { $pos

2024年10月14日 解决方法: 1、删除根目录下404.html文件 2、宝塔面板 -> 网站 -> 找到你的网站 -> 设置 -> 配置文件,找到文件里下面的代码注释掉: error_page 404 /404.html; error_page 502 /502.html; //改成 #error_page 404 /404.html; #error_page 502 /502.html;

2024年10月14日 wordpress建站中,如何只搜索指定分类下面的文章,或者搜索指定多分类下的文章,下面web建站小编给大家简单介绍一下具体实现代码! 具体代码如下: <form action="<?php bloginfo('home'); ?>" method="get"> <div> <input type="text" value="<?php echo wp_specialchars($s, 1);

2024年10月14日 利用wordpress插件建站中,如何在后台文章列表中显示文章点赞数,下面web建站小编给大家简单介绍一下具体解决方法! 打开主题下functions.php文件,新增以下代码: //~ 数字 格式化 function num2tring($num) { if ($num >= 10000) { $num = round($num / 10000 * 100) / 100 .' w'; // 以万为单位 } elseif($num >=

2024年10月14日 WordPress搜索在默认情况下是标题和内容一起搜索的,那么如何实现只搜索标题不搜内容呢?下面web建站小编给大家简单介绍一下实现方法! 在functions.php中添加下面的代码: function post_search_columns_callback($search_columns) { return ['post_title']; } add_filter('post_search_columns', 'post_search_columns

2024年10月14日 wordpress建站中,如何让首页不显示指定分类下的文章,下面web建站小编给大家简单介绍一下具体实现代码! 打开主题下的 functions.php 文件,新增以下代码: function exclude_category_home( $query ) { if ( $query->is_home ) { $query->set( 'cat', '-10, -122, -180' ); //要排除的分类ID,id前面有负号 }

2024年10月14日 在文章页面中显示评论输入框: <?php comment_form(); ?> 在文章页面中显示评论的数量: <?php comments_number('暂无评论','1条评论','% 评论');?> 评论相关参数介绍: 1、comment_form():这个函数用于显示评论表单。它可以接受一些参数,例如id_form(表单的ID)、id_submit(提交按钮的ID)、title_reply(回复标题)等。通过调整这些参数,您可

2024年10月14日 wordpress建站中如何封装一些短代码功能,下面web建站小编给大家简单介绍一下“点击展开/收缩”功能的实现方法! 1、在functions.php中新增以下代码: function xcollapse($atts, $content = null){ extract(shortcode_atts(array("title"=>""),$atts)); return '<div > <div class="xControl"&

2024年10月14日 <?php $args = array( 'category_name' => '栏目名称', 'showposts' => '10', //文章条数 ); $cn_posts = new WP_Query($args); if ($cn_posts -> have_posts() ) : while ($cn_posts -> have_posts() ) : $cn_posts -> t

2024年10月14日 WordPress生成XML站点地图每页数量限制为2000条,对于网站文章比较多的站长来说不是很友好,那么如何去掉这个限制呢?下面web建站小编给大家详细介绍一下方法! 找到主题下functions.php文件,新增以下代码: add_filter( 'wp_sitemaps_max_urls', '__wp_sitemaps_max_urls' ); function __wp_sitemaps_max_urls(){ return 2000; //改

2024年10月14日 wordpress如何隐藏网站后台登录地址,下面web建站小编给大家简单介绍一下具体实现代码! 找到主题下functions.php文件,新增以下代码: add_action('login_enqueue_scripts', 'tb_wp_login_protection'); function tb_wp_login_protection(){ if( !isset($_GET['web']) ){ header( 'Locati

2024年10月13日 wordpress如何利用WP_Query函数调用指定作者的文章?下面web建站小编给大家详细介绍一下具体实现方法! 根据作者昵称调用文章 $query = new WP_Query( 'author_name=xiaomi' ); 根据作者id调用文章 $query = new WP_Query( 'author=120' ); //调用多个作文章 $query = new WP_Query( 'author=1,2,7' ); 过滤指定

2024年10月13日 wordpress如何利用自带的代码显示页面加载时间,下面web建站小编给大家详细介绍一下具体实现代码! 具体实现代码如下: 当前页面加载时间:<?php timer_stop(3); ?> 秒

2024年10月13日 wordpress如何屏蔽(过滤)文章中所有超链接(a标签),下面web建站小编给大家详细介绍一下具体实现代码! 打开主题下functions.php文件,新增以下代码: function replace_text_wps($text){ $text=preg_replace("/<a[^>]*>(.*?)<\/a>/is", "$1", $text); return $text; } add_filter('the_

最新内容