How to add capability to author role to assign custom taxonomy terms to a custom post type?

Yes. It is some kind of mapping. So now, when I register the custom taxonomy I pass it: $caps = array( ‘manage_terms’ => ‘activate_plugins’, ‘edit_terms’ => ‘activate_plugins’, ‘delete_terms’ => ‘activate_plugins’, ‘assign_terms’ => ‘edit_posts’ ); With this result authors can now assign terms. I am just using ‘activate_plugins’ because, by default, authors do not have this … Read more

get_posts() function does not honor correct post type

This could be caused by a pre_get_posts action that doesn’t have the proper conditions/checks. For example: add_action( ‘pre_get_posts’, function( $query ) : void { if ( is_post_type_archive( ‘tribe_events’ ) ) { $query->set( ‘post_type’, ‘tribe_events’ ); } } ); Likewise if this was a page template and not a post archive they might have this in … Read more

How to automatically update ACF field value every year?

If you don’t want to use a scheduler (ex: Action Scheduler) or a cron job, and you only want to update once per year, then an option that tracks the next update time is probably the simplest approach (untested): add_action( ‘init’, static function () { $option_name=”cpt_ages_next_update”; $option = absint( get_option( $option_name ) ); if ( … Read more

How to get taxonomy category in permalink for each taxonomy OR How to give a parent page to a given taxonomy?

This worked for me (tested): add_action( ‘init’, static function () { register_taxonomy( ‘portfolio-work’, ‘post’, array( ‘hierarchical’ => true, ‘labels’ => array( ‘name’ => ‘Portfolio Works’, ‘singular_name’ => ‘Portfolio Work’, ), ‘rewrite’ => array( ‘slug’ => ‘work’, ‘with_front’ => false, ), ) ); } ); Then created new pages titled “Blog” (slug: blog) and “Work” (slug: … Read more

Change formatting of Date parameter on custom post type

Use the post_date_column_time filter to change the time format. The documentation says it changes the “published time of the post”, but it will change the scheduled time as well (ticket). Tested: add_filter( ‘post_date_column_time’, static function ( $time, $post ) { if ( ‘wp_events’ !== get_post_type( $post ) || ‘future’ !== get_post_status( $post ) ) { … Read more