WordPress Users, Roles and Capabilities

I find the capabilities one of the most difficult to grasp concepts in WordPress development. On one hand, you have the capabilities of a custom post type and on the other hand you have the capabilities of a user or user role. And then you have the 2 other capabilities options you can set when registering a custom […]

Get custom post type by custom taxonomy on the WordPress rest api

To get custom post types and filter them by custom taxonomies, you can do the following: or filter by more than one taxonomy (this means: give me posts from taxonomy 1 OR 3 OR 6): or to exclude posts with specific taxonomies: Maybe good to know: combining categories and tags means AND, so for example […]

Custom taxonomies vs post meta data

There are many articles about the difference between custom taxonomies and post meta data. Here are some differences I experienced: There is no index on the post meta value. With the builtin WP_Query functionality, you cannot search with operators like <, >, =, >=, BETWEEN, etc. in custom taxonomies, so if your values are numbers, […]

Install Titanium continuous builds

You can download and install continuous Titanium builds at: http://builds.appcelerator.com/ And then install it with something like: appc ti sdk install --branch 6_3_X 6.3.1.v20171101154403 These builds are not supported, so I only do this when the official versions have a bug that needs to be resolved asap.

URL structure of WordPress custom post types and taxonomies

Explanation about register_taxonomy and register_post_type and how this is reflected in the URL structure. register_taxonomy( 'my_newscat', ['post'], [ 'labels' => ['name' => 'News category'], 'public' => true, 'hierarchical' => true, 'show_admin_column' => true, 'rewrite' => [ 'slug' => 'newscategories' ], 'query_var' => 'newscategories' ] ); If we didn't specify a rewrite slug, we had to […]

WordPress settings API

WordPress advises to use the Settings API when programming a settings page. But as you start using it, you quickly get overwhelmed with all the arguments you have to give to functions like register_setting, add_settings_section, add_settings_field, settings_fields, do_settings_sections, add_menu_page and add_submenu_page... This is an explanation what every argument means and how it fits into the big picture. This […]

Display alarm manager entries of your app in Android

Unfortunately it's not possible to do this within the app itself as far as I know, but you can see it in a shell. In the below example I want to see all the alarm manager entries for my package my.package.name. The "when" field in my case is as Unix timestamp, so I rewrite it […]

Broadcast action on emulator

To emulate an action on an Android emulator, you can login into the shell and then broadcast some action. For e adb root adb shell am broadcast -a android.intent.action.BOOT_COMPLETED name.package.my

Show custom post types in category archives

Custom post types are not displayed in the category and tag archives by default, even if you indicated in the register_post_type call that it should support these taxonomies. The way to include them in the category and tag archives is to use the pre_get_posts action: add_action('pre_get_posts', 'mycode_pre_get_posts'); function mycode_pre_get_posts($query) { if ((is_home() || is_category() || […]

Single selected taxonomy in WordPress

The category taxonomy is by default a multiselect widget that uses checkboxes. There are some ways to only allow one selection, like implementing your own Walker_Category_Checklist. But the most simple solution is just replace the checkbox inputs with radio input boxes with some Javascript. In the example below, I have a taxonomy "level" that I want […]