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

 

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

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

 
<< Newer Posts Older Posts >>