Hugh's Blog

WordPress 显示某个分类下的文章

之前写过一个在 sidebar 下显示分类文章的,这个也是类似,就不多说了。 直接建立 template 文件。 <?php /** * Template Name: Posts By Category */ get_header(); // 获取 post 的某个字段 (分类 slug),这个是从 ...

 

WordPress 在 Sidebar 中显示某个分类下的文章

实现过程 注册 sidebar widget (register_sidebar) 添加获取分类文章的 shortcode (add_shortcode) 允许在 widget 中使用 shortcode (do_shortcode) 使用的是 cherry framework 主题,所以修改的是主题下的 sidebar-init.php 文件,也可以直接写在 functions.php 文件 <?php // Register sidebars by running cherry_widgets_init() on ...

 

HTML 跳转到有锚点的网页后自动调整位置

今天任务中有这样一个需求,假如有 a、b 两个页面,b 有锚点,从 a 上点击链接到 b (b 页面的某个锚点) 后,由于 b 页面有一个保持固定位置的头部,所以在 ...

 

WordPress 自定义上传文件类型

很简单!! 在 functions.php 文件中添加如下代码。 /** * Add custom file type */ add_filter('upload_mimes', 'custom_upload_xml'); function custom_upload_xml($mimes = array()) { $mimes = array_merge($mimes, array('xml' => 'application/xml')); return $mimes; } 添加上面代码可以将 xml 文件上传到后台中。 更多的文件类型可以到这 ...

 

PHP 实现 301 重定向

PHP 中实现 301 重定向挺简单的,代码也不复杂,无非就是对域名进行判断,不是新域名就使用 header 函数进行跳转,但是中途也出现一些问题,在此做个记录。 $host = 'www.new.com'; ...

 
<< Newer Posts Older Posts >>