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

Register custom post type

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

WordPress创建自定义widget教程

在wordpress的plugin文件夹创建textdomain_widget文件夹,textdomain是你wp的站点文本名字,然后在里面创建textdomain_widget.php文件夹。 首先创建widget文件的头部,来进行插件的相关安全性验证, 然后,添加自定义widget插件的正文部分,默认的自定义widget的格式为: 之后添加钩子: 添加高级的自定义widget,这里名字为Foo_Widget(可以自定义更改)的格式为: 之后在钩子里进行注册: Note : You must use get_field_name() and get_field_id() function to generate form element name and id.

Getting Sticky Headers and the WordPress Admin Bar to Behave

Putting a site’s logo and main navigation into a sticky header (or a fixed-position header) is a definite trend now. It’s become popular for WordPress themes as well: check out posts like all of these. In a WordPress site, however, sticky headers run into a problem when the admin bar is visible. Both the admin bar and most sticky headers […]