WordPress theme custom capabilities not works

add_action( ‘init’, ‘register_cpt_gallery’ ); function register_cpt_gallery() { $labels = array( ‘name’ => _x( ‘Galleries’, ‘gallery’ ), ‘singular_name’ => _x( ‘Gallery’, ‘gallery’ ), ‘add_new’ => _x( ‘Add New’, ‘gallery’ ), ‘add_new_item’ => _x( ‘Add New Gallery’, ‘gallery’ ), ‘edit_item’ => _x( ‘Edit Gallery’, ‘gallery’ ), ‘new_item’ => _x( ‘New Gallery’, ‘gallery’ ), ‘view_item’ => _x( ‘View … Read more

query private custom post type

If you are setting the CPT to private, that is telling wordpress not to create the dynamic page for that post type. This includes using the single-CPT.php file. If you want to have “?post_type=” pages, you’ll need to set the cpt to publicly_queryable=true, or public=true (which includes publicly_queryable). Why do you want it private (aka … Read more

Add acf field in title (admin table)

Use this to filter the title: add_action( ‘admin_head-edit.php’, ‘wpse264139_edit_post_change_title_in_list’ ); function wpse264139_edit_post_change_title_in_list() { add_filter( ‘the_title’, ‘wpse264139_construct_new_title’, 100, 2 ); }` `function wpse264139_construct_new_title( $title, $id ) { if(get_post_type($id) == ‘post_type’) { $field = get_field(‘place’, $id); return $field . ” ” . $title; } else { return $title; } } NOTE: most of the code came from: … Read more

How to use the post_title of custom post type as taxonomy

Is there a hook that actually only fires when a post gets updated and where I can get $post_before and $post_after? You’re probably looking for the post_updated hook. Usage add_action( ‘post_updated’, ‘wpse_264720_post_updated’, 10, 3 ); function wpse_264720_post_updated( $post_ID, $post_after, $post_before ) { //* Bail if this is an autosave if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE … Read more

Custom Post Type Tag Capabilities Not Working

It seems that although WP core creates four capability mappings for the built-in post_tag taxonomy (manage_terms => manage_post_tags, edit_terms => edit_post_tags, delete_terms => delete_post_tags, assign_terms => assign_post_tags) when it is registered, it uses different values when checking if the user has one of those capabilities. If you look at the implementation of the map_meta_cap function … Read more

What’s a better alternative to this code?

Thanks to those who’ve suggested fixes. I couldn’t get my normal pagination working with either, but did find an alternate solution which seems to work and which I’ll include here as possible help to others (because I’ve seen various requests for similar). <?php $wp_query = new WP_Query(); $wp_query->query(‘post_type=host&sort_by=title&order=ASC&showposts=1&paged=’.$paged ); get_template_part( ‘page-templates/partial/paginate’ ); while ($wp_query->have_posts()) : … Read more