How to filter a custom post type by custom taxonomy without 404

When you want to use a taxonomy inside a custom post type URL hierarchy, you have to register it BEFORE the custom post type. Otherwise it won’t work properly. here is a short example: function so305901_register_taxonomies() { $args = [ //your settings ]; register_taxonomy( ‘taxonomy_slug’, [‘custom_post_type_slug’], $args ); } add_action( ‘init’, ‘so305901_register_taxonomies’ ); function so305901_register_custom_post_types() … Read more

Query to get child pages of current page and display it in action hook

I was making a beginner’s mistake. I was not defining the global variable post. I publish my complete code for the community. May be useful for something like me. <?php add_action( ‘genesis_after_entry’, ‘capitulos_curso’ ); function capitulos_curso(){ global $post; $args = array( ‘post_type’ => ‘curso’, ‘posts_per_page’ => -1, ‘post_parent’ => $post->ID, ‘order’ => ‘ASC’, ‘orderby’ => … Read more

How to display custom taxonomy term meta on custom post type

1. If you need to display this informations once. For example in the page header, use get_queried_object(). echo get_term_meta( get_queried_object()->term_id, ‘blue’, true ); echo get_term_meta( get_queried_object()->term_id, ‘red’, true ); echo get_term_meta( get_queried_object()->term_id, ‘green’, true ); 2. If you need to display this informations in the each post, you must create a small loop. $terms = … Read more

Creating a non-hierarchical Taxonomy that behaves like categories

This blog post by “Gazchap” deals with exactly the situation you are, and they updated it after publishing to your follow-up problem: Fortunately, version 4.4 of WordPress introduced a filter – post_edit_category_parent_dropdown_args – that could be used to control the parent terms shown in these meta boxes. It’s designed to let the developer change the … Read more

get_post_types() can’t get some of my post type

Build in WordPress function for fetching all registered post types: get_post_types() <?php // hook into init late, so everything is registered // you can also use get_post_types where ever. Any time after init is usually fine. add_action( ‘init’, ‘wpse34410_init’, 0, 99 ); function wpse34410_init() { $types = get_post_types( [], ‘objects’ ); foreach ( $types as … Read more

Comment form on custom page template

If you want to display default WordPress comment form then you need to call comments_template() in your template. Make sure that comment_status should be open for the particular post that you want to display the comment form. <?php comments_template(); ?> Read more here https://developer.wordpress.org/reference/functions/comments_template/