Custom Post Types not queried in Custom Taxonomy archives or Native archives

Tags shared by CPTs and standard posts return only the latter, and topics archives or tag archives with only CPTs assigned return empty. As for the tag archives, that’s a default behavior in WordPress core, i.e. tag (post_tag taxonomy) and category (category taxonomy) archives will only query posts where the type is post. However, the … Read more

How can I add a shortcode to query Custom Post Type with ACF in WordPress?

I ultimately figured out getting a shortcode to work by reworking the code to the following: add_shortcode( ‘gr_shortcode’, ‘gr_shortcode’ ); function gr_shortcode() { $buffer=”<h3>Upcoming Titles</h3>”; $q = new WP_Query(array( ‘post_type’ => ‘game_release’, ‘posts_per_page’ => 3 )); while ($q->have_posts()) { $q->the_post(); $buffer = $buffer.get_the_title().'<br>’.$buffer.the_field(‘release_date’); } wp_reset_postdata(); return $buffer; }

How to inherit field value from parent post into in child / sub post

You can use get_post_field( ‘post_parent’ ) to get the parent ID of the current post. Whilst ACF is technically off-topic, FWIW you can pass the ID of a post as the second parameter to get_field. Combined together we can fashion a shortcode centre_field that will return any field value for the post’s parent. I’ve skipped … Read more

Insert Custom Post Types

You maybe want to add extra information fields, and settings for individual posts – single posts in CPT – Custom Post Types. Out of the box, WordPress gives us – ‘title’ ‘editor’ (content) ‘author’ ‘thumbnail’ (featured image, current theme must also support post-thumbnails) ‘excerpt’ ‘trackbacks’ ‘custom-fields’ ‘comments’ (also will see comment count balloon on edit … Read more

Assigning a category to a custom post type in WordPress

Couple things I’ve spotted: Your taxonomy registration register_taxonomy( ‘document-category’, ‘Documents’ should be register_taxonomy( ‘document-category’, ‘document’ – the second parameter is the post type name(s), not the post type label. If you’re programmatically inserting posts then forget using tax_input in your wp_insert_post() data args. There’s a hard-coded permissions check on the current user and there’s nothing … Read more

Role capabilities issue

I solved the issue! If you create a new CPT with the function register_post_type You have to add this line in the array with arguments ‘map_meta_cap’ => true, Now you can set capabilities to a role like below add_role(‘owner’, ‘Eigenaar’, array( ‘read’ => true, ‘publish_agendas’ => true, ‘edit_agenda’ => true, ‘edit_agendas’ => true, ‘delete_agenda’ => … Read more