-
WordPress分类页面中如何排除子分类文章
默认 WordPress 会在分类页面显示子分类文章,如果只想显示该分类的文章,而不显示子分类中的文章,可以通过下面的代码实现。 在主题文章归档模板主循环: 在上面添加: 下面添加:
WordPress 2023-12-04 30
-
wodpress wp_list_bookmarks输出友情链接
使用 参数 参数名 描述 order 升序 ASC 或 降序 DESC,默认 ASC。 limit -1 表示全部,1+整数表示要显示的个数。 category 以逗号分隔的类别ID列表,其中包含来自的链接。 category_name 要按名称检索链接的类别。 hide_invisible 是否显示或隐藏标记为“不可见”的链接。接受1|true或0|false。默认值1|true。 show_u…
WordPress 2023-12-01 46
-
wordpress文章第一个图片自动设置为特色图片
/* ------------------------------------------------------------------------- * * 设置文章第一个图片自动为特色图片 /* ------------------------------------------------------------------------- */ function autoset_featu…
WordPress 2023-02-18 542
-
wordpress取自动裁剪后的缩略图及地址
取特色图片 the_post_thumbnail(); // Without parameter ->; Thumbnail the_post_thumbnail( 'thumbnail' ); // Thumbnail (default 150px x 150px max) the_post_thumbnail( 'medium' ); // Medium resolution (default…
WordPress 2023-02-18 650
-
wordpress 升级提示另一更新正在进行
在functions.php文件中添加 ,然后刷新一下页面,在然后注释掉, /*清楚数据库更新记录*/ global $wpdb; $wpdb->query("DELETE FROM wp_options WHERE option_name = 'core_updater.lock'"); 或者 直接在数据库操作也可以,找到wp_options这个表,然后在找到这个删除core_updater.l…
WordPress 2023-01-09 524
-
wordpress 升级提示ftp
在wp-config.php 添加 define("FS_METHOD", "direct"); define("FS_CHMOD_DIR", 0777); define("FS_CHMOD_FILE", 0777);
WordPress 2023-01-09 358
-
WordPress 取当前在后台页面位置
WordPress 全局变量:$pagenow 判断后台页面位置 global $pagenow; print_r($pagenow); 网上看到这个,我试了一下没什么卵用, function get_current_post_type() { global $post, $typenow, $current_screen; //we have a post so we can just get …
WordPress 2022-09-21 697
-
wordpress 文章发布或修改时自动从内容截取设置文章标题
我的需求是,发布文章时,如果标题没有设置,则从内容里截取 一开始,网上找到一个插件,于是我把核心复制了出来,自定义修改了一下,但是在wordpress app上发布文章没有效果, https://cn.wordpress.org/plugins/autotitle-for-wordpress/ /** * 自动标题 * @return void */ function auto_title() {…
WordPress 2022-09-17 701
-
wordpress使用strtotime转为timestamp时间戳相差8小时
wordpress uses strtotime to convert timestamp to timestamp with a difference of 8 hours 假设原时间2022-09-16 15:19 使用strtotime转换后 strtotime('2022-09-16 15:19') 结果1663341544 在换成时间2022-09-16 23:19:04 时间相差8小时…
WordPress 2022-09-16 771
-
WordPress 关闭默认自带的搜索功能
在functions.php添加 function close_search_query( $query, $error = true ) { if ( is_search() && !is_admin() ) { $query->is_search = false; $query->query_vars[s] = false; $query->query[s] = false; if ( $er…
WordPress 2021-07-04 1861
-
WordPress 上传图片压缩
在主题functions.php函数文件里添加即可 图片只有jpg格式适合压缩, png不好压缩,但是可以imagewebp代替imagepng,但是ie浏览器不支持webp格式,如果用imagejpeg代替imagepng压缩的话,如果是透明的图片,那么图片会失去透明,而且会失真,所以可选择压缩, gif也不好压缩,也没必要压缩了,如果使用imagewebp压缩gif的话,我测试发现,上传报错,…
WordPress 2020-11-08 2094
-
WordPress 文章阅读量、访问量、浏览量统计记录
阅读量统计 在functions.php文件里添加 //文章阅读统计 function post_views_record() { if (is_singular()) { global $post; $post_ID = $post->ID; if ($post_ID) { $post_views = (int)get_post_meta($post_ID, 'views', true); if…
WordPress 2020-11-04 3254
-
wordpress添加自定义文章状态和获取调用文章状态
前言 我有个企业网站,一个简单商品展示型的那种网站,我想删除商品,但是还想让他不显示404页面,玩wordpress的都知道,文章只有发布出去,才会显示出来, 我想让他像京东那类电商网站一样,商品直接显示已经下架, 于是就在想,如果能给文章添加个自定义的状态,我可以通过文章状态来判断后续, 注册文章状态 下架 // 注册新的文章状态 add_action('init', function () {…
WordPress 2020-07-30 6105
-
wordpress wp_redirect
wordpress重定向 wp_redirect( string $location, int $status = 302 ) 使用 wp_redirect( $url ); exit; 例子 默认302重定向 指定301重定向 直接这样也行,php自带的 header('location:地址'); php常用的header头 https://www.blyoo.com/1371.html Wo…
WordPress 2018-10-26 2555