Hugh's Blog

WordPress 返回带 HTML 标签的内容

今天遇到一个小需求,需要在一篇文章显示另一篇文章的内容。 使用 shortcode 来实现,然后在文章中调用,shortcode 定义需要返回带 html 标签的内容。 functions.php 中添 ...

 

WordPress 获取 Portfolio 某个分类下的子分类

实现流程:get_term_by->get_term_children->loop。 <ul id="filters" class="filter nav nav-pills"> <?php // 获取 post 下的要显示的分类 slug $category_value = get_post_meta($post->ID, ...

 

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 ...

 

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 文件上传到后台中。 更多的文件类型可以到这 ...

 
<< Newer Posts Older Posts >>