Month: June 2020

Remove li from wp_nav_menu

Here is my updated attempt based on the resource shared by @shahar: And in my functions.php: Using the code above the menu is not displaying at all. Update: Here is the final code I ended up using in my functions file: And here’s the code to generate the menu in your template: menuswalker

WordPress实现jquery data-filter效果

get_the_category和get_the_terms区别

get_the_category( int $id = false ) Description #Description This tag may be used outside The Loop by passing a post id as the parameter. Note: This function only returns results from the default “category” taxonomy. For custom taxonomies use get_the_terms(). Parameters #Parameters $id (int) (Optional) default to current post ID. The post ID. Default value: false Top ↑ Return #Return (WP_Term[]) Array of WP_Term objects, one for each category […]

get_terms和get_the_terms区别

In the WordPress Codex you can find: For get_the_terms: “Retrieve the terms of the taxonomy that are attached to the post.” http://codex.wordpress.org/Function_Reference/get_the_terms For get_terms: “Retrieve the terms in a taxonomy or list of taxonomies.” http://codex.wordpress.org/Function_Reference/get_terms So, as you said, get_the_terms() will get the terms (e.g. categories) attached to a post, whereas get_terms() will retrieve the terms in […]

Query a custom post type with a custom taxonomy

WordPress自定义文章类型和分类(custom post type and taxonomy)

自定义文章类型(custom post type): 创建插件文件夹,创建custom_post_type.php文件,然后粘贴上面的代码进去,根据自己的需要修改。插件头部要设置安全验证: if ( !defined(ABSPATH)) { die(); } 后台开启插件,就可以看到自定义的post type. 自定义分类(Taxonomy): WordPress官方自定义分类模板: